-
Notifications
You must be signed in to change notification settings - Fork 5
DataAPI SDK english MT.DataAPI Endpoint method uploadAsset
Taku AMANO edited this page Aug 28, 2013
·
2 revisions
Upload a file.
POST https://your-host/your-mt-api.cgi/v1/sites/:site_id/assets/upload Detail
Name | Type | Required | Description |
---|---|---|---|
siteId | Number | Object | Function | yes | Site ID |
callback | Function | no |
XMLHttpRequest: Return a XMLHttpRequest object if request is sent via XMLHttpRequest. Return null if request is sent via IFRAME.
var data = {
file: getElementById("file-input").files[0], // File object
path: "DIRECTORY",
autoRenameIfExists: true,
normalizeOrientation: true
};
api.uploadAsset(siteId, data, function(response) {
if (response.error) {
// Handle error
return;
}
// Do stuff
});
Or
var data = {
file: getElementById("file-input"), // HTMLInputElement object
path: "DIRECTORY",
autoRenameIfExists: true,
normalizeOrientation: true
};
api.uploadAsset(siteId, data, function(response) {
if (response.error) {
// Handle error
return;
}
// Do stuff
});