This is an automated email from the ASF dual-hosted git repository. nitiraj pushed a commit to branch branch-2.6 in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.6 by this push: new 1a18822 AMBARI-23294: Ambari files view throws 500 ERROR while trying to upload/download to/from HDFS encrypted zone (nitirajrathore) (#714) 1a18822 is described below commit 1a18822d148ba59220d57fe92ba06081d70c69f1 Author: nitirajrathore <nitiraj.rath...@gmail.com> AuthorDate: Mon Apr 16 20:51:39 2018 +0530 AMBARI-23294: Ambari files view throws 500 ERROR while trying to upload/download to/from HDFS encrypted zone (nitirajrathore) (#714) --- .../main/resources/ui/app/adapters/application.js | 23 +++++++++++++++++++--- .../main/resources/ui/app/services/file-preview.js | 5 ++++- 2 files changed, 24 insertions(+), 4 deletions(-) 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 059d379..cc46922 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 @@ -18,6 +18,7 @@ import DS from 'ember-data'; import Ember from 'ember'; +import ENV from 'files-view/config/environment'; export default DS.RESTAdapter.extend({ init: function () { @@ -38,10 +39,26 @@ export default DS.RESTAdapter.extend({ instance = parts[parts.length - 2]; version = ''; } + + if (ENV.environment === 'development') { + return '/resources/files/fileops'; + } + return 'api/v1/views/' + view + version + '/instances/' + instance + '/resources/files/fileops'; }), - headers: { - 'X-Requested-By': 'ambari' - } + headers: Ember.computed(function () { + let headers = { + 'X-Requested-By': 'ambari', + 'Content-Type': 'application/json' + }; + + if (ENV.environment === 'development') { + // In development mode when the UI is served using ember serve the xhr requests are proxied to ambari server + // by setting the proxyurl parameter in ember serve and for ambari to authenticate the requests, it needs this + // basic authorization. This is for default admin/admin username/password combination. + headers['Authorization'] = 'Basic YWRtaW46YWRtaW4='; + } + return headers; + }) }); diff --git a/contrib/views/files/src/main/resources/ui/app/services/file-preview.js b/contrib/views/files/src/main/resources/ui/app/services/file-preview.js index e4484c2..ea5bf6f 100644 --- a/contrib/views/files/src/main/resources/ui/app/services/file-preview.js +++ b/contrib/views/files/src/main/resources/ui/app/services/file-preview.js @@ -21,6 +21,7 @@ import FileOperationMixin from '../mixins/file-operation'; export default Ember.Service.extend(FileOperationMixin, { fileSelectionService: Ember.inject.service('files-selection'), + logger: Ember.inject.service('alert-messages'), selectedFiles: Ember.computed.alias('fileSelectionService.files'), selected: Ember.computed('selectedFiles', function () { return this.get('selectedFiles').objectAt(0); @@ -83,7 +84,9 @@ export default Ember.Service.extend(FileOperationMixin, { return resolve(response); }, (responseError) => { _self.set('isLoading', false); - return reject(error); + var error = this.extractError(responseError); + this.get('logger').danger("Failed to preview file.", error); + return reject(responseError); }); }); }, -- To stop receiving notification emails like this one, please contact niti...@apache.org.