@twinscom/uploader-client
v1.0.0
Published
The reference implementation of a JavaScript client for uploader
Downloads
2
Maintainers
Readme
uploader-js-client
Requirements
- jQuery
API
var uploader = TWINSCOM.uploader.make({
projectInstanceId: "project-instance-id",
baseUri: "http://localhost/",
apiKey: "api-key",
acceptLanguage: "de" // optional
});
uploader.uploadFile({
file: document.querySelector("#file-input").files[0],
onSuccess: function (fileModel) {
console.log(fileModel);
},
onError: function (message) {
console.error(message);
},
onProgress: function (progress) {
var percent = Math.round(100 / progress.total * progress.loaded);
console.log(percent + "%");
}
});
uploader.getFile({
id: "file-id",
onSuccess: function (fileModel) {
console.log(fileModel);
},
onError: function (message) {
console.error(message);
}
});
uploader.getFiles({
ids: [
"file-id",
"other-file-id"
],
onSuccess: function (fileModels) {
console.log(fileModels);
},
onError: function (message) {
console.error(message);
}
});
uploader.deleteFile({
id: "file-id",
onSuccess: function () {
console.log("Deleted!");
},
onError: function (message) {
console.error(message);
}
});