-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Unable to upload files (images) #3615
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
Comments
I have an interesting update..... curl -X POST Results in an error. 404 Not Found but curl -X POST does not result in an error. I can however retrieve a file via both HTTP and HTTPS. |
Some more troubleshooting... Files still get served. But I noticed that CURL posting a file via HTTPS still does not work. And posting it via HTTP does - it reports back that it was put into a specific directory (/var/www/parse/files/appid/xxxx.jpg). By dumb luck - I happened to setup a directory that matches what's found in the FileRouter.js file (/node_modules/parse-server/lib/Routers) - so things are MOSTLY working... but not 100%. |
Ok - so I quasi have this figured out. I have parse server installed under I have a whole slew of files stored under If in my HTTPS section of the NGINX file (/etc/nginx/sites-enabled/default) I have this ... I get those files no problem. Parse API calls give me an url like myserver/parse/files/appid/filename.jps However. I thought filerouter.js did some fancy routing to send you to that directory should it not be found in grid store.... but perhaps I am wrong. Can anyone suggest how parse server can default to to that physical directory should the actual file not be found in the gridstore mongo table? |
SCORE. This is what I had to do to fix my problem. First off - I am not using grid store... Gridstore does work just fine if you start out fresh but if you have a few thousand images stored in a folder and not in gridstore - I have not figured out a way to push all those into mongo.gridstore and retain links to existing entries... Anyhow... first I am using parse-server-fs-adapter Secondly - for my /etc/nginx/sites-enabled/default file (no I won't go into details on obtaining an SSL certificate and all that here).... server {
useful for debugging otherwise turn off to "hide" filesautoindex on;
} HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/through to Parse Serverserver {
} Parse is installed under The physical files are stores under |
Issue Description
Since moving to my own server (from parse.com), I am unable to upload images/files of any size. Downloading files/images and updating/fetching data works fine.
The only issues that seem to match mine refer to file sizes being large with a fix bing to update nginx.conf (as well as the server and location contexts in the relevant site config files) to have the setting :
client_max_body_size 100m;
This fix has not worked for me - I've tried uploading files as small as 2mb with no luck.
I have tried to upload images as part of an array in one object (where an array is expected), as well as a simply one off file in another object (where no array is expected).
An error happens with both cases.
Steps to reproduce
Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.
In my macOS application I initialize Parse as so:
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id configuration) {
configuration.applicationId = @"myappid";
configuration.clientKey = @"myClientKey";
configuration.server = @"https://myservername.com/parse/";
}]];
I am able to retrieve and update records normally.... both through macOS app and restFUL via linux box.
I attempt to upload an image using :
.
//openDlg is a file dialog box that allows the user to select the file. I've omitted the code for simplicity here.
NSString *filePath = [[openDlg URL] path];
PFFile *theImage = [PFFile fileWithName:filename contentsAtPath:filePath];
//set various fields
newFlyerObject[@"clientObjectId"] = @"test";
newFlyerObject[@"locationObjectId"] = @"test";
//set the image
newFlyerObject[@"image"] = theImage;
[newFlyerObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError error) {
if(error){
NSLog(@"** Error saving new flyer (%@) %@",error,error.userInfo);
} else {
//Everything was saved
[self.dataFlyers addObject:objectToSave];
[self.tableFlyerList reloadData];
}
[self changeLevelValue:-1 eventDescription:@"LoadFlyerFromDisc (A)"];
}];
Expected Results
File and values saved to the database.
Actual Outcome
Nothing is saved and the error is :
*** Error saving new flyer (Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}) {
NSDebugDescription = "JSON text did not start with array or object and option to allow fragments not set.";
}
If I remove the line newFlyerObject[@"image"] = theImage;
The object is saved fine (albeit with no image data).
Environment Setup
Installed parse-server-example followed by the required NPMs:
express
mongoldb-runner
parse-server
parse-server-fs-adapter
Server
Database
Logs/Trace
Include all relevant logs. You can turn on additional logging by configuring VERBOSE=1 in your environment.
I cleaned out the logs and ran the code.
NO log files located in /var/www/parse/logs
NO log files located in /var/log/nginx
The text was updated successfully, but these errors were encountered: