Skip to content

ParseFile & useMasterKey: pass options through to RESTController from saveBase64 #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ParseFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ export default class ParseFile {
* @param {Object} options A Backbone-style options object.
* @return {Parse.Promise} Promise that is resolved when the save finishes.
*/
save(options?: { success?: any, error?: any }) {
save(options?: { useMasterKey?: boolean, success?: any, error?: any }) {
options = options || {};
var controller = CoreManager.getFileController();
if (!this._previousSave) {
if (this._source.format === 'file') {
this._previousSave = controller.saveFile(this._name, this._source).then((res) => {
this._previousSave = controller.saveFile(this._name, this._source, options).then((res) => {
this._name = res.name;
this._url = res.url;
return this;
});
} else {
this._previousSave = controller.saveBase64(this._name, this._source).then((res) => {
this._previousSave = controller.saveBase64(this._name, this._source, options).then((res) => {
this._name = res.name;
this._url = res.url;
return this;
Expand Down Expand Up @@ -256,7 +256,7 @@ var DefaultController = {
return CoreManager.getRESTController().ajax('POST', url, source.file, headers);
},

saveBase64: function(name: string, source: FileSource) {
saveBase64: function(name: string, source: FileSource, options?: { useMasterKey?: boolean, success?: any, error?: any }) {
if (source.format !== 'base64') {
throw new Error('saveBase64 can only be used with Base64-type sources.');
}
Expand All @@ -267,7 +267,7 @@ var DefaultController = {
data._ContentType = source.type;
}
var path = 'files/' + name;
return CoreManager.getRESTController().request('POST', path, data);
return CoreManager.getRESTController().request('POST', path, data, options);
}
};

Expand Down