Skip to content

DataAPI SDK english MT.DataAPI Endpoint method uploadAsset

Taku AMANO edited this page Aug 28, 2013 · 2 revisions

uploadAsset

Upload a file.

POST https://your-host/your-mt-api.cgi/v1/sites/:site_id/assets/upload Detail

Parameters

Name Type Required Description
siteId Number | Object | Function yes Site ID
callback Function no

Returns

XMLHttpRequest: Return a XMLHttpRequest object if request is sent via XMLHttpRequest. Return null if request is sent via IFRAME.

Example

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
});
Clone this wiki locally