Skip to content

Commit 6f67e8d

Browse files
author
Igor Khomenko
committed
adopt Content module API to different file storages
1 parent bd5e0e0 commit 6f67e8d

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

js/modules/qbContent.js

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ ContentProxy.prototype = {
8585
callback(err, null);
8686
} else {
8787
var uri = parseUri(createResult.blob_object_access.params);
88-
var uploadParams = { url: 'https://' + uri.host };
88+
var uploadUrl = uri.protocol + "://" + uri.authority + uri.path;
89+
var uploadParams = {url: uploadUrl};
90+
8991
var data;
9092
if(isBrowser){
9193
data = new FormData();
@@ -116,12 +118,6 @@ ContentProxy.prototype = {
116118
if (err) {
117119
callback(err, null);
118120
} else {
119-
if (isBrowser) {
120-
createResult.path = result.Location.replace('http://', 'https://');
121-
} else {
122-
createResult.path = result.PostResponse.Location;
123-
}
124-
125121
// Mark file as uploaded
126122
//
127123
_this.markUploaded({id: fileId, size: size}, function(err, result){
@@ -140,28 +136,12 @@ ContentProxy.prototype = {
140136
upload: function(params, callback){
141137
Utils.QBLog('[ContentProxy]', 'upload');
142138

143-
this.service.ajax({url: params.url, data: params.data, dataType: 'xml',
139+
this.service.ajax({url: params.url, data: params.data, dataType: 'text',
144140
contentType: false, processData: false, type: 'POST'}, function(err,xmlDoc){
145141
if (err) {
146142
callback (err, null);
147143
} else {
148-
if (isBrowser) {
149-
// AWS S3 doesn't respond with a JSON structure
150-
// so parse the xml and return a JSON structure ourselves
151-
var result = {}, rootElement = xmlDoc.documentElement, children = rootElement.childNodes, i, m;
152-
for (i = 0, m = children.length; i < m ; i++) {
153-
result[children[i].nodeName] = children[i].childNodes[0].nodeValue;
154-
}
155-
callback (null, result);
156-
157-
} else {
158-
var parseString = xml2js.parseString;
159-
parseString(xmlDoc, function(err,result) {
160-
if (result) {
161-
callback (null, result);
162-
}
163-
});
164-
}
144+
callback (null, {});
165145
}
166146
});
167147
},

0 commit comments

Comments
 (0)