vsivsi / meteor-file-collection

Extends Meteor Collections to handle file data using MongoDB gridFS.
http://atmospherejs.com/vsivsi/file-collection
Other
159 stars 37 forks source link

Getting 404 when file-collection requests /gridfs/fs/_resumable #84

Closed lightpriest closed 8 years ago

lightpriest commented 8 years ago

I've setup according to the examples on the README, but noticed that when the client uploads it returns 404 for HEAD /gridfs/fs/_resumable requests (and for each chunk uploaded). I looked at the app example and noticed that the route used is /md5/:md5. This fixed it for me.

I think specifying the route at /:md5 collides with the requests to /_resumable. I wanted to open a small PR to fix that on the README, but it appears in many places so I decided to open an issue instead assuming maybe it was intentional.

vsivsi commented 8 years ago

This may actually be a bug. The .../_resumable/... route should probably always take precedence when enabled. I can't think of a time when that wouldn't be the desired/expected behavior. Investigating a fix now...

vsivsi commented 8 years ago

The dev branch has my proposed fix for this issue. There were two bugs: one was an express route precedence issue for application specified HEAD/GET/POST routes that match /_resumable, and the other was an additional multipart header parser reentry issue for POST requests matching the above criteria. The unit tests have also been updated to fail if this issue resurfaces.

Please try it out if you get the chance. Either way I'll publish this to Atmosphere tomorrow as version 1.3.1. Thanks!

vsivsi commented 8 years ago

Fixed in 1.3.1 on Atmosphere now.

lightpriest commented 8 years ago

:+1: Thanks for the quick response and fix!

srbdev commented 8 years ago

I am running 1.3.6 and it looks I am getting the same issue. I am not sure if it would be the same bug but the /gridfs/fs/_resumable route results in a 404 Not Found.

vsivsi commented 8 years ago

@srbdev Are you remembering to insert a document for the file to be uploaded?

See e.g.: https://github.com/vsivsi/meteor-file-sample-app/blob/master/sample.coffee#L39

srbdev commented 8 years ago

I am. The fileError callback gets called but I can't get an error message to print. Looking at the console I get the 404 for a POST to http://localhost:3000/gridfs/fs/_resumable.

vsivsi commented 8 years ago

Okay, please open another issue. These things are pretty difficult to remotely debug if I can't see code. If you can make a minimal reproduction case (a working Meteor project that demonstrates the problem) and put it in a public repo, I'll be happy to take a look.

srbdev commented 8 years ago

I'll see if I can make such minimal reproduction. One last question: do you think Flow Router could interfere with the path? Thank you for being responsive and the help!

vsivsi commented 8 years ago

Re: flow router. It's possible... It's more likely to be something related to the values of the file IDs used by MongoDB and Resumable. IMO.

srbdev commented 8 years ago

I see... is the resumableIdentifier parameter in the POST for http://localhost:3000/gridfs/fs/_resumable supposed to be same as the one set here: https://github.com/vsivsi/meteor-file-sample-app/blob/master/sample.coffee#L40? In my case they are different.

srbdev commented 8 years ago

I made sure that these two ID's are the same and it solved my issue. Thanks again for your help!