Skip to content

Commit

Permalink
Bugfix: Team storage upload file in user storage (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewoox authored and dynamiccast committed Oct 17, 2016
1 parent f5b3cba commit 7f8fe7f
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions assets/app/components/file-explorer/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ export default Ember.Component.extend({
return path;
}),

requestParamsAsString: Ember.computed('requestParams', function() {
let data = '';
for (var i in this.get('requestParams')) {
if (data !== '') {
data += '&';
}
data += i + '=' + this.get('requestParams')[i];
}
return data;
}),

downloadFile(filename) {
let path = this.get('pathToString').substring(1) + filename;
Ember.$.ajax({
Expand All @@ -131,7 +142,7 @@ export default Ember.Component.extend({
data: { filename: path }
})
.then((response) => {
let url = '/api/files/download?' + this.get('target') + '=true&filename=' + encodeURIComponent(path) + '&token=' + encodeURIComponent(response.token);
let url = '/api/files/download?' + this.get('requestParamsAsString') + '&filename=' + encodeURIComponent(path) + '&token=' + encodeURIComponent(response.token);
window.location.assign(url);
});
},
Expand Down Expand Up @@ -170,9 +181,7 @@ export default Ember.Component.extend({
type: 'PATCH',
headers: { Authorization : 'Bearer ' + this.get('session.access_token')},
url: '/api/files?filename=./' + old + '&newfilename=' + dest,
data: {
teams: true
}
data: this.get('requestParams')
})
.then(() => {
this.toast.success('File has been moved successfully');
Expand All @@ -185,7 +194,7 @@ export default Ember.Component.extend({
uploadFile(file) {
let req = new XMLHttpRequest();
this.set('req', req);
req.open('POST', '/api/upload?' + this.get('target') + '=true&filename=' + file.name + '&dest=' + this.get('targetDirectory') + file.name);
req.open('POST', '/api/upload?' + this.get('requestParamsAsString') + '&filename=' + file.name + '&dest=' + this.get('targetDirectory') + file.name);
req.setRequestHeader('Authorization', 'Bearer ' + this.get('session.access_token'));
req.upload.onprogress = (event) => {
if (event.lengthComputable) {
Expand Down Expand Up @@ -227,9 +236,7 @@ export default Ember.Component.extend({
type: 'POST',
headers: { Authorization : 'Bearer ' + this.get('session.access_token')},
url: '/api/files?filename=' + path,
data: {
teams: true
}
data: this.get('requestParams')
})
.then(() => {
this.toast.success('File has been created successfully');
Expand All @@ -247,9 +254,7 @@ export default Ember.Component.extend({
type: 'PATCH',
headers: { Authorization : 'Bearer ' + this.get('session.access_token')},
url: '/api/files?filename=' + oldName + '&newfilename=' + newName,
data: {
teams: true
}
data: this.get('requestParams')
})
.then(() => {
this.toast.success('File has been renamed successfully');
Expand All @@ -266,9 +271,7 @@ export default Ember.Component.extend({
type: 'DELETE',
headers: { Authorization : 'Bearer ' + this.get('session.access_token')},
url: '/api/files?filename=' + path,
data: {
teams: true
}
data: this.get('requestParams')
})
.then(() => {
this.toast.success('File has been removed successfully');
Expand Down

0 comments on commit 7f8fe7f

Please sign in to comment.