|
@@ -24,46 +24,19 @@ ARKIWI.Uploader = function (uploaderUrl, defaultParameters, formName, sessionUpl
|
|
|
ARKIWI.Uploader.constructor = ARKIWI.Uploader;
|
|
|
|
|
|
/* Invia un file all'uploader. */
|
|
|
-//ARKIWI.Uploader.prototype.upload = function (form, destinationFolderBase64, callbacks) {
|
|
|
-// form = $(form);
|
|
|
-//
|
|
|
-// form.attr('method', 'POST');
|
|
|
-// form.attr('action', this.uploaderUrl + '/upload/' + this.sessionId + '/' + destinationFolderBase64 + '/?' + this.defaultParameters);
|
|
|
-// form.attr('id', this.formName);
|
|
|
-// form.attr('enctype', 'multipart/form-data');
|
|
|
-// form.attr('target', 'arkiwi_hidden_iframe');
|
|
|
-//
|
|
|
-// form.append('<input type="hidden" value="' + this.formName + '" name="' + this.sessionUploadProgressName + '" />');
|
|
|
-//
|
|
|
-// $(':file', form).attr('name', this.sessionId);
|
|
|
-//
|
|
|
-// form.ajaxForm({
|
|
|
-// beforeSend: function () {
|
|
|
-// callbacks.beforeSend();
|
|
|
-// },
|
|
|
-// uploadProgress: function (event, position, total, percentComplete) {
|
|
|
-// callbacks.uploadProgress(event, position, total, percentComplete);
|
|
|
-// },
|
|
|
-// complete: function (xhr) {
|
|
|
-// callbacks.complete(xhr);
|
|
|
-// },
|
|
|
-// error: function (xhr, status, error) {
|
|
|
-// throw 'Arkiwi.upload(): error ' + error;
|
|
|
-// }
|
|
|
-// });
|
|
|
-//
|
|
|
-// form.submit();
|
|
|
-//};
|
|
|
-
|
|
|
ARKIWI.Uploader.prototype.upload = function (file, destinationFolderBase64, callbacks) {
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
xhr.withCredentials = true;
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
- xhr.upload.addEventListener("progress", function(e) {}, false);
|
|
|
+ xhr.upload.addEventListener("progress", function(e) {
|
|
|
+ callbacks.progress(e);
|
|
|
+ }, false);
|
|
|
|
|
|
- xhr.upload.addEventListener("load", function(e){}, false);
|
|
|
+ xhr.upload.addEventListener("load", function(e){
|
|
|
+ callbacks.load(e);
|
|
|
+ }, false);
|
|
|
|
|
|
xhr.open("POST", this.uploaderUrl + '/upload/' + destinationFolderBase64 + '/?' + this.defaultParameters, true);
|
|
|
|
|
@@ -75,6 +48,26 @@ ARKIWI.Uploader.prototype.upload = function (file, destinationFolderBase64, call
|
|
|
xhr.send(fileData);
|
|
|
};
|
|
|
|
|
|
+/* Aggiunge o sovrascrive i metadati di un file. */
|
|
|
+ARKIWI.Uploader.prototype.listMetadata = function (item64, callback) {
|
|
|
+ $.ajax({
|
|
|
+ url: this.uploaderUrl + '/listmetadata/' + item64 + '/?' + this.defaultParameters,
|
|
|
+ type: 'GET',
|
|
|
+ async: true,
|
|
|
+ cache: false,
|
|
|
+ context: this,
|
|
|
+ data: '',
|
|
|
+ dataType: 'json',
|
|
|
+ error: function (xhr, status, error) {
|
|
|
+ throw 'Arkiwi.listMetadata(): status ' + status + ' error ' + error;
|
|
|
+ },
|
|
|
+ success: function (result, status, xhr) {
|
|
|
+ if (callback != undefined)
|
|
|
+ callback(result);
|
|
|
+ },
|
|
|
+ complete: function (xhr, status) {}
|
|
|
+ });
|
|
|
+};
|
|
|
|
|
|
/* Aggiunge o sovrascrive i metadati di un file. */
|
|
|
ARKIWI.Uploader.prototype.metadata = function (jsonKVString, callback) {
|