file DELETE support
This commit is contained in:
@@ -74,6 +74,26 @@ export class FilesController {
|
||||
};
|
||||
}
|
||||
|
||||
deleteHandler() {
|
||||
return (req, res, next) => {
|
||||
// enforce use of master key for file deletions
|
||||
if(!req.auth.isMaster){
|
||||
next(new Parse.Error(Parse.Error.OPERATION_FORBIDDEN,
|
||||
'Master key required for file deletion.'));
|
||||
return;
|
||||
}
|
||||
|
||||
this._filesAdapter.deleteFile(req.config, req.params.filename).then(() => {
|
||||
res.status(200);
|
||||
// TODO: return useful JSON here?
|
||||
res.end();
|
||||
}).catch((error) => {
|
||||
next(new Parse.Error(Parse.Error.FILE_DELETE_ERROR,
|
||||
'Could not delete file.'));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Find file references in REST-format object and adds the url key
|
||||
* with the current mount point and app id.
|
||||
@@ -119,6 +139,12 @@ export class FilesController {
|
||||
this.createHandler()
|
||||
);
|
||||
|
||||
router.delete('/files/:filename',
|
||||
Middlewares.allowCrossDomain,
|
||||
Middlewares.handleParseHeaders,
|
||||
this.deleteHandler()
|
||||
);
|
||||
|
||||
return router;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user