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

Allowed crossdomain for Parse.file upload with POST #169

Closed
wants to merge 1 commit into from
Closed

Allowed crossdomain for Parse.file upload with POST #169

wants to merge 1 commit into from

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
@@ -74,7 +77,6 @@ router.post('/files', function(req, res, next) {
'Filename not provided.'));
});

// TODO: do we need to allow crossdomain and method override?
router.post('/files/:filename',
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