Skip to content

Posting file pointers to REST API #660

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
brandly opened this issue Feb 25, 2016 · 4 comments
Closed

Posting file pointers to REST API #660

brandly opened this issue Feb 25, 2016 · 4 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@brandly
Copy link

brandly commented Feb 25, 2016

Hey. We're transitioning onto parse-server. We had old code POSTing images to the REST API, immediately followed by POSTing data to another collection, with a pointer to that earlier image file.

When we were fully on Parse, before using parse-server, we supplied data like this:

'imageObject': {
  'name': data.name,
  '__type': "File"
}

where only a name and a __type were necessary to define that relationship.

Once we moved to parse-server, this code was breaking. It boiled down to this line which also looks for a url. We needed to change out the data we're POSTing to something like this:

'imageObject': {
  'name': data.name,
  'url': data.url,
  '__type': "File"
}

Maybe this information could be provided in migration docs, since we didn't see it there.

It might also be worth mentioning that we're now using the S3Adapter to store our newly-created files in a bucket.

Thanks for everything! Overall, this migration is going far smoother than we could've expected.

cc @kyleseaman

@drew-gross
Copy link
Contributor

I think we could probably just remove the check for the URL. @nlutsenko thoughts?

@nlutsenko
Copy link
Contributor

Files are required to have a url at the moment of submitting them via REST API.
There are a lot of things that could go wrong when this is not true, like storage mechanisms or beforeSave/afterSave hooks. This is true for every single endpoint and is specified in the REST API guide.

This said, we could remove the limitation here, but I would actually recommend moving your file pointers to use a different system of pointers for files, or sticking a URL there might also be the case.

@drew-gross
Copy link
Contributor

How would their code have worked on Parse.com then? Would the pointer have just referenced the most recent file with that name?

@nlutsenko
Copy link
Contributor

Actually, I take it back - we do enforce guarantee of files by name, so we might as well remove this restriction. And if we can't serve the file from a URL - then, yeah, that actually is absolutely fine, but to match it closer to api.parse.com - going to remove the restriction.

@nlutsenko nlutsenko self-assigned this Feb 26, 2016
@nlutsenko nlutsenko added the type:bug Impaired feature or lacking behavior that is likely assumed label Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

3 participants