parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

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

Open mikepaggi opened this issue 10 years ago • 8 comments

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); 
                    });

                });

            });`

mikepaggi avatar Feb 19 '16 16:02 mikepaggi

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...

gfosco avatar Feb 19 '16 22:02 gfosco

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 avatar Feb 19 '16 22:02 mikepaggi

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?

mikepaggi avatar Feb 19 '16 22:02 mikepaggi

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.

gfosco avatar Feb 19 '16 23:02 gfosco

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 avatar Feb 20 '16 23:02 mikepaggi

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 avatar Feb 22 '16 00:02 mikepaggi

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 avatar Feb 22 '16 17:02 mikepaggi

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.

gfosco avatar Mar 06 '16 11:03 gfosco