Skip to content

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

Closed

Description

@johndoehelloworld

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.

Activity

  1. dplewis commented on Jul 10, 2018

    @dplewis
    Member

    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.

  2. johndoehelloworld commented on Jul 12, 2018

    @johndoehelloworld
    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?

  3. dplewis commented on Jul 17, 2018

    @dplewis
    Member

    Can you output your logs VERBOSE=1?

  4. georgesjamous commented on Jul 18, 2018

    @georgesjamous
    Contributor

    @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 ?

  5. stale commented on Sep 18, 2018

    @stale

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions