Deleting a Parse File using cloud code


Hey guys, I’m having issues trying to delete a Parse file.

This is my deleteFile function in my cloud code:

Parse.Cloud.define('deleteFile', function(req, res) {
	const { img } = req.params;
		method: 'DELETE',
		url: img,
		headers: {
			'X-Parse-Application-Id': 'appID',
			'X-Parse-Master-Key': 'masterKey'
		.then(httpResponse => console.log(httpResponse.text))
		.catch(error => console.log(error));

When running it in my app I keep getting Unsupported protocol null any ideas on what I’m doing wrong?



hi @benmarte it depends what is the content of img.

According to the documentation to success the delete, img should be ${serverURL}/files/${}


Have you taken a look at this SO question

Working with files is really weird as you have to perform httpRequests within the cloud code. I chose to store files in an S3 location and later in Cloudinary in order to get around this - probably not helpful to tell you that, but I recall it being such a pain that I changed tack.


Hey guys I thought I posted the link to the SO question I was using as the base for my example here is the link: but clearly, that is not working or no longer works.


did u confirm that the img value you assigned to url is the file name received when storing the file and not an object reference ?

see reference here:


I read somewhere that the files are deleted when the reference to the file is deleted, but i’m not sure where.and how reliable is this info.
I assume that files are stored in mongodb as default , but what you are doing is to store them as regular files is S3 , right ?


I am saving directly in mongodb not S3, and yes I ran this function on the img var before sending it to the cloud code:

img = img.substring(img.lastIndexOf('/') + 1);

And I verified the filename is the same on the DB as the img var I am sending to the cloud code.

I also tried deleting via curl in my terminal and I get this result:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<pre>Cannot DELETE /parse/files/turn2/d35012f25c28e98b906be3411fa4de3f_Screen%20Shot%202019-02-26%20at%2010.54.09%20AM.png</pre>

What am I doing wrong?



Hope this tutorial will help you:

1 Like