@@ -323,14 +323,23 @@ class ParseFile {
323
323
* Deletes the file from the Parse cloud.
324
324
* In Cloud Code and Node only with Master Key.
325
325
*
326
+ * @param {object } options
327
+ * * Valid options are:<ul>
328
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
329
+ * be used for this request.
330
+ * <pre>
326
331
* @returns {Promise } Promise that is resolved when the delete finishes.
327
332
*/
328
- destroy ( ) {
333
+ destroy ( options ? : FullOptions = { } ) {
329
334
if ( ! this . _name ) {
330
335
throw new ParseError ( ParseError . FILE_DELETE_UNNAMED_ERROR , 'Cannot delete an unnamed file.' ) ;
331
336
}
337
+ const destroyOptions = { useMasterKey : true } ;
338
+ if ( options . hasOwnProperty ( 'useMasterKey' ) ) {
339
+ destroyOptions . useMasterKey = options . useMasterKey ;
340
+ }
332
341
const controller = CoreManager . getFileController ( ) ;
333
- return controller . deleteFile ( this . _name ) . then ( ( ) => {
342
+ return controller . deleteFile ( this . _name , destroyOptions ) . then ( ( ) => {
334
343
this . _data = null ;
335
344
this . _requestTask = null ;
336
345
return this ;
@@ -540,11 +549,13 @@ const DefaultController = {
540
549
} ) ;
541
550
} ,
542
551
543
- deleteFile : function ( name ) {
552
+ deleteFile : function ( name : string , options ? : FullOptions ) {
544
553
const headers = {
545
554
'X-Parse-Application-ID' : CoreManager . get ( 'APPLICATION_ID' ) ,
546
- 'X-Parse-Master-Key' : CoreManager . get ( 'MASTER_KEY' ) ,
547
555
} ;
556
+ if ( options . useMasterKey ) {
557
+ headers [ 'X-Parse-Master-Key' ] = CoreManager . get ( 'MASTER_KEY' ) ;
558
+ }
548
559
let url = CoreManager . get ( 'SERVER_URL' ) ;
549
560
if ( url [ url . length - 1 ] !== '/' ) {
550
561
url += '/' ;
0 commit comments