看源码一目了然啊:
save: function() {
var options = null;
var saveOptions = {};
if(arguments.length === 1) {
options = arguments[0];
} else if(arguments.length === 2) {
saveOptions = arguments[0];
options = arguments[1];
}
var self = this;
if (!self._previousSave) {
if(self._source) {
var upload = require('./browserify-wrapper/upload');
upload(self, AV, saveOptions);
} else if(self.url && self.metaData['__source'] == 'external') {
//external link file.
var data = {
name: self._name,
ACL: self._acl,
metaData: self._metaData,
mime_type: self._guessedType,
url: self._url
};
self.previousSave = AV.request("files", self._name, null, 'POST', data).then(function(response) {
self._name = response.name;
self._url = response.url;
self.id = response.objectId;
if(response.size) {
self._metaData.size = response.size;
}
return self;
});
}
}
return self.previousSave.thenRunCallbacks(options);
}
};
};