Skip to content
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

Cloud code doesn't automatically parse File objects #2294

Closed
smassin opened this issue Jul 15, 2016 · 6 comments
Closed

Cloud code doesn't automatically parse File objects #2294

smassin opened this issue Jul 15, 2016 · 6 comments

Comments

@smassin
Copy link

smassin commented Jul 15, 2016

Issue Description

When uploading a ParseFile as a parameter to cloud code it does not automatically parse the object and transform it into the ParseFile on the cloud code side. On parse.com it would do this automatically. Essentially I could save a file on the client and then pass the ParseFile as a parameter in a cloud call and then on the cloud side it would show up as a ParseFile. Documented here: https://parse.com/docs/rest/guide#objects-data-types . Instead the cloud side just sees a normal JSON object that would represent a ParseFile. Even using the Parse Client JS SDK has the same problem.

To further muck up the situation, parse-server allows these JSON objects to be saved in File columns but when they are retrieved they are still a basic JSON object and calling .url() causes the server to spin forever and never complete the request.

  1. Was this functionality intentionally removed?
  2. While its fine that it doesn't automatically convert to a ParseFile, the Parse SDK doesn't provide a way to create a Parse.File manually from such a JSON structure. Any thoughts?

Steps to reproduce

  1. Run code such as:
var parseFile = new Parse.File("theFile", document.getElementById("theFile").files[0]);
parseFile.save().then(function(file){
   Parse.Cloud.run("cloudFunction", {file:file})
})

Expected Results

Parse.Cloud.define("cloudFunction", function(request, response) {
 response.success(request.params.file instanceof Parse.File);
})

request.params.file instanceof Parse.File === true;

Actual Outcome

request.params.file instanceof Parse.File === false;

Environment Setup

  • Server
    • parse-server version: 2.2.14
    • Localhost or remote server? Azure
  • Database
    N/A -- Completely parse-server software issue

Logs/Trace

Outcomes above should be detailed enough.

@flovilmart
Copy link
Contributor

That seems to be valid, do you want to try to fix it?

@smassin
Copy link
Author

smassin commented Jul 15, 2016

Ha, didn't see that coming. I haven't actually compiled the source myself.
I could have a look if you can give me an idea which file deals with parsing the request parameters?

EDIT: Even still, I don't know the correct procedure for converting a JSON structure in a Parse.File. Is that documented somewhere?

@flovilmart
Copy link
Contributor

@smassin this is a community project :)

We already have a parse for Dates, https://github.com/ParsePlatform/parse-server/blob/master/src/Routers/FunctionsRouter.js#L63

Need to add a new Parser for files.

@flovilmart
Copy link
Contributor

I can give it a go, that seems pretty straight forward

@smassin
Copy link
Author

smassin commented Jul 15, 2016

Thanks I appreciate it.

flovilmart added a commit that referenced this issue Jul 15, 2016
drew-gross pushed a commit that referenced this issue Jul 19, 2016
…ons (#2297)

* fix for #2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode #2214

* Adds regression tests for #2204
@smassin
Copy link
Author

smassin commented Jul 25, 2016

Confirmed working. Thanks a lot @flovilmart 👍

rsouzas pushed a commit to back4app/parse-server that referenced this issue Mar 15, 2017
…ons (parse-community#2297)

* fix for parse-community#2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode parse-community#2214

* Adds regression tests for parse-community#2204
rsouzas pushed a commit to back4app/parse-server that referenced this issue Mar 16, 2017
…ons (parse-community#2297)

* fix for parse-community#2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode parse-community#2214

* Adds regression tests for parse-community#2204
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

2 participants