Cannot restore Parse.File from aggregation query result #1456
Labels
bounty:$50
Bounty applies for fixing this issue (Parse Bounty Program)
type:feature
New feature or improvement of existing feature
New Issue Checklist
Issue Description
A
Parse.File
is stored in the DB as only the filename. When retrieving raw data from the DB (e.g. via a MongoDB aggregation query), the file data is in some cases not - and cannot be reliably be - parsed by the Parse Server internals. This means that instead of a validParse.File
, the only file data available is the filename, e.g.abc.txt
. To convert this into a validParse.File
withParse.File.fromJSON(...)
, the URL needs to be provided as well. The URL is however is composed by the Parse Server storage adapter.Effectively that means it's not possible to easily recreate a Parse.File from aggregate query data. At least in Cloud Code, it should be possible to easily recreate the URL without having to manually access the storage adapter's
getFileLocation
method.Steps to reproduce
{ file: 'abc.txt' }
.Parse.File.fromJSON(...)
cannot be used to recreate an already saved file.#Actual Outcome
A file URL has to be composed by manually accessing the storage adapter.
Expected Outcome
Parse.File should provide a method that auto-composes the URL, for example:
Alternative
Parse Server could parse the query results for specific markers to substitute an occurrence of a raw file object with an actual
Parse.File
object. But that may cause conceptual issues, see parse-community/parse-server#7868.Hack
Return the file name with a key of a file field of the same class on which the aggregation query runs. This will make Parse Server convert it to a Parse File because the schema demands so. That hack may break anytime though.
Environment
Server
5.1.1
Client
3.4.1
Logs
n/a
The text was updated successfully, but these errors were encountered: