The data browser is built for Chrome, Firefox, Safari, and IE9 and above. Please upgrade your browser, or download Google Chrome to get the best experience.
You're looking at our forums archive. If you're looking for help, head over to the Parse Developers Google Group or check out the parse.com tag on Stack Overflow.
Help Google Group Stack Overflow
Back to Questions

How can I delete a file?

13 votes 1 answer 18.4k views 10 months ago

13

1 Answer

-34

Deleting an object will not delete any file that is referenced by any of its columns.

Files are static assets and may be referenced from different places. For example, your app may have cached an object with a reference to this file. Even if the original object has been deleted from the server, cached data should continue working without impacting the user experience in most cases.

If you still want to delete a file, you can do so through the REST API. You will need to provide the master key in order to be allowed to delete a file. Note that the name of the file must be the name in the response of the upload operation, rather than the original filename.

    curl -X DELETE \
        -H "X-Parse-Application-Id: <YOUR_APPLICATION_ID>" \
        -H "X-Parse-Master-Key: <YOUR_MASTER_KEY>" \
        https://api.parse.com/1/files/<FILE_NAME>

Clean Up

You may have files which are not referenced by any object in your app, in which case it is not possible to delete them through the REST API. You may request a clean up of these unused files in your app's Settings page. Keep in mind that doing so might break any functionality which depended on accessing unreferenced files through their URL property. Files which are currently associated with an object will not be affected.

Why can't I delete a file using the SDK?

Since files do not have ACLs, their write access cannot be restricted to a specific user. Since leaving files open to deletion by any arbitrary user is not a great security measure, we require that a master key is used to delete a file. Since client SDKs cannot use the master key, you will need to use the REST API.

How to delete all files that I have uploaded onto parse? Or, delete a file after uploading is done ?

- Bharath about 2 years ago

You should be able to delete a file using the PFFile class in code, a strange omission! Please add this functionality, I shouldn't have to add a REST interface or occasionally press a clean up button!

- moneybudgie almost 2 years ago