AMBARI-20137. File upload from Ambari File View does not work in Chrome 56.0.2924.87 and IE 11.(gauravn7)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e1cb3b1e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e1cb3b1e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e1cb3b1e Branch: refs/heads/branch-feature-AMBARI-12556 Commit: e1cb3b1e2a01c04bac96ea3b5b5957848eec721a Parents: 98f40e3 Author: Gaurav Nagar <[email protected]> Authored: Thu Feb 23 19:09:10 2017 +0530 Committer: Gaurav Nagar <[email protected]> Committed: Thu Feb 23 19:12:34 2017 +0530 ---------------------------------------------------------------------- .../ambari/view/commons/hdfs/UploadService.java | 2 +- .../resources/ui/app/adapters/application.js | 6 ++++++ .../resources/ui/app/components/upload-file.js | 19 +++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e1cb3b1e/contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/UploadService.java ---------------------------------------------------------------------- diff --git a/contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/UploadService.java b/contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/UploadService.java index 26a4873..a2fe7eb 100644 --- a/contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/UploadService.java +++ b/contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/UploadService.java @@ -94,7 +94,7 @@ public class UploadService extends HdfsService { try { if (!path.endsWith("/")) path = path + "/"; - String filePath = path + contentDisposition.getFileName(); + String filePath = path + new String(contentDisposition.getFileName().getBytes("ISO8859-1"),"UTF-8"); uploadFile(filePath, uploadedInputStream); return Response.ok( getApi().fileStatusToJSON(getApi().getFileStatus(filePath))) http://git-wip-us.apache.org/repos/asf/ambari/blob/e1cb3b1e/contrib/views/files/src/main/resources/ui/app/adapters/application.js ---------------------------------------------------------------------- diff --git a/contrib/views/files/src/main/resources/ui/app/adapters/application.js b/contrib/views/files/src/main/resources/ui/app/adapters/application.js index 4042851..059d379 100644 --- a/contrib/views/files/src/main/resources/ui/app/adapters/application.js +++ b/contrib/views/files/src/main/resources/ui/app/adapters/application.js @@ -20,6 +20,12 @@ import DS from 'ember-data'; import Ember from 'ember'; export default DS.RESTAdapter.extend({ + init: function () { + Ember.$.ajaxSetup({ + cache: false + }); + }, + namespace: Ember.computed(function() { var parts = window.location.pathname.split('/').filter(function(i) { return i !== ""; http://git-wip-us.apache.org/repos/asf/ambari/blob/e1cb3b1e/contrib/views/files/src/main/resources/ui/app/components/upload-file.js ---------------------------------------------------------------------- diff --git a/contrib/views/files/src/main/resources/ui/app/components/upload-file.js b/contrib/views/files/src/main/resources/ui/app/components/upload-file.js index 96686db..8a14272 100644 --- a/contrib/views/files/src/main/resources/ui/app/components/upload-file.js +++ b/contrib/views/files/src/main/resources/ui/app/components/upload-file.js @@ -58,13 +58,19 @@ export default Ember.Component.extend(OperationModal, { _checkIfFileIsNotDirectory: function(file) { return new Ember.RSVP.Promise((resolve, reject) => { + let isSuccess = false; + if (!Ember.isNone(file.size) && file.size <= 4096) { // Directories generally have less equal to 4096 bytes as size var reader = new FileReader(); reader.onerror = function() { - return reject(); + if(isSuccess) { + return; + } + return reject(reader.error); }; reader.onloadstart = function() { + isSuccess = true; reader.abort(); return resolve(); }; @@ -92,7 +98,6 @@ export default Ember.Component.extend(OperationModal, { }, fileLoaded: function(file) { - this._checkIfFileIsNotDirectory(file).then(() => { var url = this.get('fileOperationService').getUploadUrl(); var uploader = FileUploader.create({ @@ -118,8 +123,14 @@ export default Ember.Component.extend(OperationModal, { return false; }); } - }, () => { - console.error("Cannot add a directory."); + }, (error) => { + console.error("Cannot add a directory.", error); + this.send('close'); + let message = "Cannot add a directory "; + if(file && file.name) { + message = message + file.name; + } + this.get('logger').danger(message); }); },
