diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js
index ddfcfcd3d8..f1fc71c6ce 100644
--- a/apps/files_sharing/js/files_drop.js
+++ b/apps/files_sharing/js/files_drop.js
@@ -72,34 +72,43 @@
return true;
},
+ setFileIcon: function (fileName,fileIcon) {
+ $('#public-upload ul li[data-name="' + fileName + '"]').html(fileIcon);
+ $('[data-toggle="tooltip"]').tooltip();
+ },
+
initialize: function () {
$(document).bind('drop dragover', function (e) {
// Prevent the default browser drop action:
e.preventDefault();
});
var output = this.template();
+ var fileName = undefined;
$('#public-upload').fileupload({
type: 'PUT',
dropZone: $('#public-upload'),
sequentialUploads: true,
add: function(e, data) {
Drop.addFileToUpload(e, data);
+ fileName = escapeHTML(data.files[0].name);
//we return true to keep trying to upload next file even
//if addFileToUpload did not like the privious one
return true;
},
done: function(e, data) {
// Created
- if (data.jqXHR.status === 201) {
- var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type);
- $('#public-upload ul li[data-name="' + escapeHTML(data.files[0].name) + '"]').html(' ' + escapeHTML(data.files[0].name));
- $('[data-toggle="tooltip"]').tooltip();
- } else {
- var name = data.files[0].name;
- OC.Notification.showTemporary(OC.L10N.translate('files_sharing', 'Could not upload "{filename}"', {filename: name}));
- $('#public-upload ul li[data-name="' + escapeHTML(name) + '"]').html(output({isUploading: false, name: escapeHTML(name)}));
- $('[data-toggle="tooltip"]').tooltip();
- }
+ var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type);
+ var fileIcon = ' ' + fileName;
+ Drop.setFileIcon(fileName,fileIcon);
+ },
+ fail: function(e, data, errorThrown) {
+ OC.Notification.showTemporary(OC.L10N.translate(
+ 'files_sharing',
+ 'Could not upload "{filename}"',
+ {filename: fileName}
+ ));
+ var fileIcon = output({isUploading: false, name: fileName});
+ Drop.setFileIcon(fileName,fileIcon);
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);