Skip to content

Commit 965eb8b

Browse files
committed
[feature] upload data type change from base64 to form data.
1 parent 66af49d commit 965eb8b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/file.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ module.exports = function(AV) {
336336
} else if (typeof(File) !== "undefined" && data instanceof File) {
337337
this._source = readAsync(data, type);
338338
this._isFileObject = true;
339+
this._fileObject = data;
339340
} else if(AV._isNode && global.Buffer.isBuffer(data)) {
340341
// use global.Buffer to prevent browserify pack Buffer module
341342
this._source = AV.Promise.as(data.toString('base64'), guessedType);
@@ -545,7 +546,7 @@ module.exports = function(AV) {
545546
* @param {Object} options A Backbone-style options object.
546547
* @return {AV.Promise} Promise that is resolved when the save finishes.
547548
*/
548-
save: function() {
549+
save: function() {
549550
var options = null;
550551
var saveOptions = {};
551552
if(arguments.length === 1) {
@@ -561,7 +562,7 @@ save: function() {
561562
// TODO: remove this code and use qiniu SDK
562563
var dataFormat;
563564
self._previousSave = self._source.then(function(data, type) {
564-
dataFormat = data;
565+
dataFormat = self._fileObject || data;
565566
return self._qiniuToken(type);
566567
}).then(function(response) {
567568
self._url = response.url;

0 commit comments

Comments
 (0)