Skip to content

Commit 66af49d

Browse files
committed
[feature] update the dist/av.js .
1 parent 8c10fd6 commit 66af49d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

dist/av.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,7 @@ module.exports = function(AV) {
18901890
this._isBlob = true;
18911891
} else if (typeof(File) !== "undefined" && data instanceof File) {
18921892
this._source = readAsync(data, type);
1893+
this._isFileObject = true;
18931894
} else if(AV._isNode && global.Buffer.isBuffer(data)) {
18941895
// use global.Buffer to prevent browserify pack Buffer module
18951896
this._source = AV.Promise.as(data.toString('base64'), guessedType);
@@ -2099,7 +2100,7 @@ module.exports = function(AV) {
20992100
* @param {Object} options A Backbone-style options object.
21002101
* @return {AV.Promise} Promise that is resolved when the save finishes.
21012102
*/
2102-
save: function() {
2103+
save: function() {
21032104
var options = null;
21042105
var saveOptions = {};
21052106
if(arguments.length === 1) {
@@ -2111,10 +2112,11 @@ module.exports = function(AV) {
21112112
var self = this;
21122113
if (!self._previousSave) {
21132114
if(self._source) {
2114-
if (this._isBlob) {
2115+
if (this._isBlob || this._isFileObject) {
21152116
// TODO: remove this code and use qiniu SDK
2116-
self._previousSave = self._source.then(function(blob, type) {
2117-
self._blob = blob;
2117+
var dataFormat;
2118+
self._previousSave = self._source.then(function(data, type) {
2119+
dataFormat = data;
21182120
return self._qiniuToken(type);
21192121
}).then(function(response) {
21202122
self._url = response.url;
@@ -2124,7 +2126,7 @@ module.exports = function(AV) {
21242126
var uptoken = response.token;
21252127

21262128
var data = new FormData();
2127-
data.append("file", self._blob, self._name);
2129+
data.append("file", dataFormat, self._name);
21282130
data.append("key", self._qiniu_key);
21292131
data.append("token", uptoken);
21302132

@@ -2147,7 +2149,6 @@ module.exports = function(AV) {
21472149
handled = true;
21482150

21492151
delete self._qiniu_key;
2150-
delete self._blob;
21512152
if (xhr.status >= 200 && xhr.status < 300) {
21522153
var response;
21532154
try {

0 commit comments

Comments
 (0)