Years later I happened upon this question as this SO page is linked from a closed issue on ParseServer->S3-Adapter github repo.
The information above, and in the docs, is slightly confusing. What is written in the Docs is that the URL will need to be:
https://YOUR.PARSE-SERVER.HERE/parse/files/...profile.png
This is correct, but only in the sense that you need to provide the path to your Parse Server, the "files" directory, and the file name itself. If you have multiple apps running from the same Parse Server (as is my case) this gets bit tricky.
What is suggested above - and is marked correct - is wrong or is no longer accurate (four years later) given that this isn't being run on Parse's own servers any longer.
Passing the file name by itself will not work. You need to pass in a valid URL - e.g.
http://localhost:8000/APP-NAME/files/FILE-NAME
Unlike in the documentation you don't need /parse/
. What replaces /parse/
is, instead, the name of your application.
What worked perfectly for me was:
// note: endpoint is defined outside of this function
// the endpoint is the app/server url - e.g.
// http://localhost:8000/some_parse_app_name
Parse.Cloud.define('deleteFile', (request) => {
let encodedFileName = encodeURI(request.params.fileName)
Parse.Cloud.httpRequest({
headers: {
'X-Parse-Application-Id': appId,
'X-Parse-Master-Key': masterKey
},
method: 'DELETE',
url: `${endpoint}/files/${encodedFileName}`,
}).then(function (httpResponse) {
// success
console.log('Request succeeded: ' + httpResponse.text)
}, function (httpResponse) {
// error
console.error('Request failed with response code ' + httpResponse.status)
})
})