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

Can't save to any object in Cloud code (updated title) #513

Closed
mikepaggi opened this issue Feb 19, 2016 · 8 comments
Closed

Can't save to any object in Cloud code (updated title) #513

mikepaggi opened this issue Feb 19, 2016 · 8 comments

Comments

@mikepaggi
Copy link

I'm not sure if it's an issue or if i'm doing something wrong or not but I can't seem to get files to upload in Cloud code. Now I did create a GridFS bucket in my MongoDB with a name but also not sure how it knows to save to it? I kept my code for what gets returned from the saving of the file, but i also was chaining with .url() before that. (not sure why i can't get my code to preview correctly below but should help get the idea of what i'm trying to do.)

`return breweryLabelPromise = breweryLabelPromise.then(function(){

                return Parse.Cloud.httpRequest({
                    url: singleReturnedUntappdBeer.brewery.brewery_label
                }).then(function(labelDownload){

                    return labelDownload.buffer;

                }).then(function(breweryLabelData){

                    var breweryLabelFile = new Parse.File(singleReturnedUntappdBeer.brewery.brewery_label, { base64: breweryLabelData.toString("base64") } );
                    return breweryLabelFile.save().then(function(returnedBreweryLabelURL){
                        console.log("Here is the returned saved Brewery Label URL: " + returnedBreweryLabelURL);
                        breweryModelPush.set('brewery_label', returnedBreweryLabelURL); 
                    });

                });

            });`
@gfosco
Copy link
Contributor

gfosco commented Feb 19, 2016

What is output in your console in the response from .save()? Change the console to comma delimit things:

console.log("Here is... ", returnedBreweryLabelURL);

I'm hoping it is a Parse.File object, and then I'm wondering where does it fail for you...

@mikepaggi
Copy link
Author

It never hits it...I'm just getting a code 141 in my response. Sorry I should of mentioned that part :-)

I feel like it's failing on the method there.

@mikepaggi
Copy link
Author

Is there anything specific with my MongoDB database for when setting this up? Is it a default name its looking for? I named mine Label so how do i reference to save in that GridFS bucket?

@gfosco
Copy link
Contributor

gfosco commented Feb 19, 2016

add some more logging then to find out where it stops, and tell us any error messages... log everything.

check out FilesController and the gridstore adapter to see how it all works.

@mikepaggi
Copy link
Author

It stops at the saving the file....what should I log there to see if it is saving correctly? I've been trying a few different options. I even created a GridFS bucket in my MongoDB just default named "File" to see if that is where it needs to save too, but I don't see anything. Is that not how you save files is to a separate GridFS bucket in MongoDB?

The documentation doesn't seem that complete when it comes to Parse Server exactly where we manage our own data more

@mikepaggi
Copy link
Author

It also seems like i'm just having issues altogether with saving objects in Cloud code. Do I need to include the JavaScript SDK to help me write in cloud code, or is that already accessible?

@mikepaggi
Copy link
Author

when it hits the error on the save I see this output in console when I output the error variable

ParseObjectSubclass { className: 'Brewery', _objCount: 0, _localId: 'local0' }
ParseObjectSubclass { className: 'Brewery', _objCount: 1, _localId: 'local1' }
ParseObjectSubclass { className: 'Brewery', _objCount: 2, _localId: 'local2' }

@mikepaggi mikepaggi changed the title Can't upload files in Cloud code Can't save to any object in Cloud code (updated title) Feb 22, 2016
@gfosco
Copy link
Contributor

gfosco commented Mar 6, 2016

The JavaScript SDK is available to you in cloud code, through the Parse global, and is already configured and initialized for your app. Make sure you're passing serverURL as a configuration parameter to ParseServer.

It's been a while, are you still having an issue here?... If so, please open a new issue and provide your cloud code and details (or create a test.) Thanks.

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