Hello @dmonni ,
First, you have to answer the question - “Will be uploaded files publicly accessible to any visitor or access is somehow regulated and restricted?”. I’ll give an answer for both solutions, so you can pick one which meets your needs.
About app rebuild
By default (as mentioned in FAQ) files is placed to .meteor/local/build/programs/server
and there is a reason behind it. Placing files into build/
won’t trigger app rebuild and hot code push.
Also in FAQ, we mention “Note: All files will be removed as soon as your application rebuilds
” as if you stop/start app or change Server code it will trigger rebuild process and wipe everything under build/
directory. That’s why we recommend keeping files somewhere above meteor project directory, like /data/uploads/
. Mind the leading /
- it’s a root of File System.
Storage path permissions
You’ve mentioned permission issues placing files into very root directory, well it’s easy to solve with two Linux commands (will work for Mac too):
mkdir -p /data/uploads
chmod 755 /data
chmod -R 777 /data/uploads
Storage Options
If you don’t want to store files at 3rd party server and at the same time placing files to FileSystem is too boring for you, you’re free to use GridFS it let you store files at your own mongo, so everything under control. But really - storing files on FS is okay, and won’t eat server’ RAM at all.
Publicly available files
It’s a good idea to serve publicly available files with proxy/web server like Nginx or Apache as node.js ain’t a perfect solution to serve files. As you don’t need to build authentication and permissions logic - no need to involve node.js here.
There is public
flag available on FilesCollection#Constructor, which will tell to the library to build absolute URLs to the files, so files can be served with Nginx, Apache or any other proxy/web server, just point its root to the upload directory or vice versa.
Files with access control
We have multiple ways to control access to the files: protected
, interceptDownload
, downloadCallback
you can read about each of them and other security tips at our wiki.
I hope this information will help you to pick right solution and to solve your needs.
Do not hesitate to put your questions to our issues on GitHub, we have a great and experienced community there, someone will certainly help you to find a proper solution.