Production - "File Not Found :("
See original GitHub issueHey. I’m having an issue with Meteor-Files on production. When I try to reach file locally then there is no problem, file is available via link http://localhost/cdn/storage/Documents/3JsddXYv76Z9L9uaw/original/3JsddXYv76Z9L9uaw.jpg (generated by ‘link’ helper). When I deploy my application to custom server and run in it production mode then I am not able to reach files - I get error File Not Found :( (I use link helper on production as well and get same link just with localhost replaced by IP address).
My setup: Local OS: Mac OS 10.14 Production OS: Ubuntu 14.04 Meteor: METEOR@1.5.1 Meteor-Files: ostrio:files@1.8.2
Here is how I initialize collection:
const Documents = new FilesCollection({
  collectionName: 'Documents',
  allowClientCode: false,
  storagePath: function() {
    return Meteor.isProduction ? '/home/documents' : `${process.env.PWD}/assets`;
  },
  permissions: 0777,
  parentDirPermissions: 0777,
  onBeforeUpload: function (file) {
    ...
  }
});
Collection is of course published & subscribed. There is no problem with uploading files (file is uploaded correctly to destination folder) and is inserted to db collection on both local and production.
With thanks to debug mode I have server logs:
- When uploading file (everything seems to work fine here):
 
[FilesCollection] [File Start Method] file.jpg - JDY5FrvLFHwm9NSAh
[FilesCollection] [Upload] [DDP Start Method] Got #-1/1 chunks, dst: file.jpg
[FilesCollection] [Upload] [DDP] Got #1/1 chunks, dst: file.jpg
[FilesCollection] [Upload] [DDP] Got #-1/1 chunks, dst: file.jpg
[FilesCollection] [Upload] [finish(ing)Upload] -> /home/documents/JDY5FrvLFHwm9NSAh.jpg
[FilesCollection] [Upload] [finish(ed)Upload] -> /home/documents/JDY5FrvLFHwm9NSAh.jpg
[FilesCollection] [_preCollectionCursor.observe] [changed]: JDY5FrvLFHwm9NSAh
[FilesCollection] [_preCollectionCursor.observe] [removed]: JDY5FrvLFHwm9NSAh
- When trying to access file in application:
 
[FilesCollection] [download(/cdn/storage/Documents/JDY5FrvLFHwm9NSAh/original/JDY5FrvLFHwm9NSAh.jpg)] [_404] File not found
3 Quite often I get such log on server (both local and production) when running in debug mode:
[FilesCollection] [find(undefined, undefined)]
Folder /home/documents on production server has 777 rights set.
Due to that issue I can’t open any uploaded files on production as they return 404. I looked for other issues which seemed to be related but none of answers helped. Hope there is some way to fix that issue.
Thanks for your time and help in advance!
Issue Analytics
- State:
 - Created 5 years ago
 - Comments:9 (5 by maintainers)
 

Top Related StackOverflow Question
Hey, issue was solved by updating meteor and moving to docker deployment.
@joinee thank you for update on than one. I guess it was updating Meteor-Files package itself along with meteor (we improve our packages constantly)