Skip to content

Unable to upload files (images) #3615

Closed
@PunkStarStudios

Description

@PunkStarStudios

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

    • parse example server version : 2.15.9
    • parse-server version : 2.3.6
    • parse-server-fs-adapter version : 1.0.1
    • Operating System: Ubuntu 14.04.5 LTS
    • Hardware: ASUSTeK rack server X86_64, P9D-M Series
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Local
  • Database

    • MongoDB version: 3.0.14
    • Storage engine: Storage Engine? Mongo is locally installed.
    • Hardware: ASUSTeK rack server X86_64, P9D-M Series
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Local

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions