Skip to content

Conversation

@skavinvarnan
Copy link

Fix for #118

Allowed crossdomain for the route
POST /files/:filename

This works when uploading a file with Base64 and byte. How ever it doesn't work when uploading with Content-Type image/png

Works
var base64 = "V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE=";
var file = new Parse.File("myfile.txt", { base64: base64 });
file.save();

Works
var bytes = [ 0xBE, 0xEF, 0xCA, 0xFE ];
var file = new Parse.File("myfile.txt", bytes);
file.save();

Doesn't work
var file = new Parse.File("myfile.zzz", fileData, "image/png");
file.save();

Reason
When uploading an image with the Content-Type image options request is made
OPTIONS /files/:filename


Note: I haven't used the middlewares.allowCrossDomain method. Please review my code before merge

@skavinvarnan skavinvarnan changed the title Adding crossdomain for Parse.file upload with POST Allowed crossdomain for Parse.file upload with POST Feb 2, 2016
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best method is to just pass middlewares.allowCrossDomain here in the route.

router.post('/files/:filename',
                  middlewares.allowCrossDomain,
                  bodyParser.raw({type: '*/*', limit: '20mb'}),
                  middlewares.handleParseHeaders,
                  processCreate);

gfosco added a commit that referenced this pull request Feb 3, 2016
@gfosco
Copy link
Contributor

gfosco commented Feb 3, 2016

I made this fix in master. Thanks! 👍

@gfosco gfosco closed this Feb 3, 2016
@skavinvarnan
Copy link
Author

@gfosco Thanks. Sorry i was not aware of the syntax.

montymxb pushed a commit to montymxb/parse-server that referenced this pull request Feb 14, 2016
Missing PSR4 update on CONTRIBUTING.md
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

Successfully merging this pull request may close these issues.

2 participants