You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by gn...@apache.org on 2017/02/23 13:39:37 UTC

ambari git commit: AMBARI-20137. File upload from Ambari File View does not work in Chrome 56.0.2924.87 and IE 11.(gauravn7)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 01b0080cb -> df0793801


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/df079380
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/df079380
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/df079380

Branch: refs/heads/branch-2.5
Commit: df0793801d7dae03d526fd3daecd4e500597d7bd
Parents: 01b0080
Author: Gaurav Nagar <gr...@gmail.com>
Authored: Thu Feb 23 19:09:10 2017 +0530
Committer: Gaurav Nagar <gr...@gmail.com>
Committed: Thu Feb 23 19:09:10 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/df079380/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/df079380/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/df079380/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);
       });
 
     },