Skip to content

Request to delete PFFile from Parse Server using REST DELETE with master key returns 404 #4879

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

Closed
johndoehelloworld opened this issue Jul 7, 2018 · 5 comments

Comments

@johndoehelloworld
Copy link

johndoehelloworld commented Jul 7, 2018

We use GitHub Issues for bugs.

If you have a non-bug question, ask on Stack Overflow or Server Fault:

If you have a vulnerability disclosure, please follow our policy available here https://github.com/parse-community/parse-server/blob/master/SECURITY.md

You may also search through existing issues before opening a new one: https://github.com/parse-community/parse-server/issues?utf8=%E2%9C%93&q=is%3Aissue

--- Please use this template. If you don't use this template, your issue may be closed without comment. ---

Issue Description

My request to delete PFFile from Parse Server using REST DELETE with master key returns 404. Code:

Parse.Cloud.httpRequest({
method: 'DELETE',
url: profilePhotoLargeSizedImageURL,
headers: {
'X-Parse-Application-Id': parseConfig.appId,
'X-Parse-Master-Key': parseConfig.masterKey
}
}).then(function (httpResponse) {
logger.log(groupLogger, destroyAvatarImagesFromGroup() | Successfully deleted file at ${profilePhotoLargeSizedImageURL})
}, function (httpResponse) {
logger.log(groupLogger, destroyAvatarImagesFromGroup() | Failed to delete file at ${profilePhotoLargeSizedImageURL} | HTTP Response Status: ${httpResponse.status})
})

I know that the URL is right since when I access it in browser, it returns the image.

I'm using Google Cloud Storage (parse-server-gcs-adapter).

Question: How do I delete files stored as PFFiles?

Related question: How do I overwrite PFFiles?

Note that I'm classifying this as a bug since calling delete on a PFFile is supposed to delete the file. I also asked this question on Stack Overflow, but no luck with help. I'm really hoping I get help here.

Steps to reproduce

Call delete on PFFile URL as so:

Parse.Cloud.httpRequest({
method: 'DELETE',
url: profilePhotoLargeSizedImageURL,
headers: {
'X-Parse-Application-Id': parseConfig.appId,
'X-Parse-Master-Key': parseConfig.masterKey
}
}).then(function (httpResponse) {
logger.log(groupLogger, destroyAvatarImagesFromGroup() | Successfully deleted file at ${profilePhotoLargeSizedImageURL})
}, function (httpResponse) {
logger.log(groupLogger, destroyAvatarImagesFromGroup() | Failed to delete file at ${profilePhotoLargeSizedImageURL} | HTTP Response Status: ${httpResponse.status})
})

Expected Results

Calling delete on PFFile from Parse Server using REST DELETE should delete the file in Google Cloud

Actual Outcome

Request returns 404

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.7.2
    • Operating System: Mac OS High Sierra 10.13.5 (17F77)
    • Hardware: iMac
    • Localhost or remote server? Local server, but using Google Cloud Storage adapter
  • Database

    • MongoDB version: 3.6.3
    • Storage engine: ?
    • Hardware: iMac
    • Localhost or remote server? Local server, but using Google Cloud Storage adapter

Logs/Trace

Include all relevant logs. You can turn on additional logging by configuring VERBOSE=1 in your environment.

@dplewis
Copy link
Member

dplewis commented Jul 10, 2018

I wouldn't recommend using Parse.Cloud.httpRequest. Instead use the request node package.

There exists a test for this

https://github.com/parse-community/parse-server/blob/master/spec/ParseFile.spec.js#L91

Can you try to create a failing test? Ensure your keys are correct.

@johndoehelloworld
Copy link
Author

I noticed in the test that it passes the rest api key. I included that in my headers, and it still returns 404. I tried it with google cloud storage adapter and also without any adapters simply stored in Mongo – no luck. Thoughts anyone?

@dplewis
Copy link
Member

dplewis commented Jul 17, 2018

Can you output your logs VERBOSE=1?

@georgesjamous
Copy link
Contributor

georgesjamous commented Jul 18, 2018

@johndoehelloworld
First make sure that "parseConfig.appId" is returning the correct info, not sure what "parseConfig" is.
Also, I don't know if this could cause problems but if you are using a file key try to included also.
Since the test is passing, seems like its problem from your end.
Also, are you able to access the file from Parse ? and/or delete it from other SDKs ?

@stale
Copy link

stale bot commented Sep 18, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants