Updated status code at 202
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@133432 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
98b4ee5354
commit
cf8b8b7c76
|
@ -416,152 +416,4 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
}
|
||||
return out;
|
||||
}-*/;
|
||||
|
||||
|
||||
// /**
|
||||
// * Inits the file reader.
|
||||
// */
|
||||
// public void initFileReader() {
|
||||
// initW3CFileReader(instance, MultipleDilaogUpload.FILE_DELEMITER);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Gets the files selected.
|
||||
// *
|
||||
// * @param instance the instance
|
||||
// * @param fileDelimiter the file delimiter
|
||||
// * @return the files selected
|
||||
// */
|
||||
// public static native String initW3CFileReader(MultipleDilaogUpload instance, String fileDelimiter) /*-{
|
||||
// console.log("initW3CFileReader");
|
||||
//
|
||||
// if (window.FileReader) {
|
||||
// console.log("before load");
|
||||
// var drop = $wnd.$('#drop_target')[0];
|
||||
// console.log("drop is " + drop);
|
||||
//
|
||||
// function cancel(e) {
|
||||
// if (e.preventDefault) {
|
||||
// e.preventDefault();
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// function addEventHandler(obj, evt, handler) {
|
||||
// if (obj.addEventListener) {
|
||||
// // W3C method
|
||||
// obj.addEventListener(evt, handler, false);
|
||||
// } else if (obj.attachEvent) {
|
||||
// // IE method.
|
||||
// obj.attachEvent('on' + evt, handler);
|
||||
// } else {
|
||||
// // Old school method.
|
||||
// obj['on' + evt] = handler;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// addEventHandler(drop, 'drop', function(e) {
|
||||
// e = e || window.event; // get window.event if e argument missing (in IE)
|
||||
// if (e.preventDefault) {
|
||||
// e.preventDefault();
|
||||
// } // stops the browser from redirecting off to the image.
|
||||
//
|
||||
// var servlet = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::servlet;
|
||||
//
|
||||
// var opts = {
|
||||
// url : servlet,
|
||||
// type : "POST",
|
||||
// processData : false
|
||||
// };
|
||||
//
|
||||
// var idfolder = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::idFolder;
|
||||
// console.log("idfolder: " + idfolder);
|
||||
//
|
||||
// var uploadType = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::type;
|
||||
// console.log("uploadType: " + uploadType);
|
||||
//
|
||||
// var dt = e.dataTransfer;
|
||||
// var files = dt.files;
|
||||
//
|
||||
// var filesSelected = "";
|
||||
//
|
||||
// for (i = 0; i < files.length; i++) {
|
||||
// filesSelected += files[i].name + fileDelimiter;
|
||||
// }
|
||||
// console.log("filesSelected: " + filesSelected);
|
||||
//
|
||||
//// var files = filese
|
||||
//// var files = filesSelected.split(fileDelimiter);
|
||||
// console.log("files: " + files);
|
||||
//
|
||||
// instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::isLimitExceeded(I)(files.length);
|
||||
//
|
||||
// instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::generateFakeUploaders(Ljava/lang/String;Ljava/lang/String;)(filesSelected,idfolder);
|
||||
//
|
||||
// instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::createJsonKeyForFiles()();
|
||||
//
|
||||
// var jsonKeys = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::jsonKeys;
|
||||
// console.log("jsonKeys: " + jsonKeys);
|
||||
//
|
||||
// for (var i = 0; i < files.length; i++) {
|
||||
// var file = files[i];
|
||||
//// var reader = new FileReader();
|
||||
//
|
||||
// var xhr = new XMLHttpRequest();
|
||||
//// var upload = xhr.upload;
|
||||
//
|
||||
//// upload.fileIndex = i;
|
||||
//// upload.fileObj = file;
|
||||
//// upload.downloadStartTime = new Date().getTime();
|
||||
//// upload.currentStart = upload.downloadStartTime;
|
||||
//// upload.currentProgress = 0;
|
||||
//// upload.startData = 0;
|
||||
//
|
||||
//// console.log("upload: " + upload.toString());
|
||||
// // add listeners
|
||||
//
|
||||
//// upload.addEventListener("progress", progress, false);
|
||||
//// upload.addEventListener("load", load, false);
|
||||
//
|
||||
// xhr.open(opts.type, opts.url, true);
|
||||
//// var boundary = "AJAX--------------" + (new Date).getTime();
|
||||
//// var contentType = "multipart/form-data; boundary=" + boundary;
|
||||
//// xhr.setRequestHeader("Content-Type", contentType);
|
||||
// // Use native function(Chrome 5+ ,Safari 5+ and Firefox 4+), for dealing
|
||||
// // with multipart/form-data and boundray generation
|
||||
//
|
||||
// var formdata = new FormData(); // see
|
||||
// // https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Using_FormData_objects
|
||||
// // 'file' can be any string which you would like to associte with
|
||||
// // uploaded file even for example file.type eg:
|
||||
// // formdata.append(file.type, file);
|
||||
// // formdata.append(file.fileName, file);
|
||||
//
|
||||
// formdata.append("isOverwrite", "false");
|
||||
//
|
||||
// // $wnd.exportCreateJsonKeyForFiles();
|
||||
// //
|
||||
// // $wnd.exportAddNewSubmitToMonitor();
|
||||
//
|
||||
// formdata.append("client_upload_keys", jsonKeys);
|
||||
// formdata.append("uploadType", uploadType);
|
||||
// formdata.append("idFolder", idfolder);
|
||||
// formdata.append('uploadFormElement', file);
|
||||
//
|
||||
// xhr.send(formdata);
|
||||
//
|
||||
// instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload::addNewSubmitToMonitor()();
|
||||
//
|
||||
//// reader.readAsText(file);
|
||||
// }
|
||||
// return false;
|
||||
// })
|
||||
//
|
||||
// // Tells the browser that we *can* drop on this target
|
||||
// addEventHandler(drop, 'dragover', cancel);
|
||||
// addEventHandler(drop, 'dragenter', cancel);
|
||||
// } else {
|
||||
// $wnd.$('#drop_target')[0].innerHTML = 'Your browser does not support the HTML5 FileReader.';
|
||||
// }
|
||||
// }-*/;
|
||||
}
|
||||
|
|
|
@ -614,7 +614,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
|
||||
xhr.onreadystatechange=function() {
|
||||
if (xhr.readyState === 4){ //if complete
|
||||
if(xhr.status === 200 || xhr.status === 201){ //either is "OK" (200) or is "Accepted" (201)
|
||||
if(xhr.status === 200 || xhr.status === 202){ //either is "OK" (200) or is "Accepted" (202)
|
||||
// console.log("status is OK");
|
||||
//success
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue