I want users to be able to upload files such as images, PDFs, Word Docs, Audio Files etc. I want to know whether I should store all the files on a server locally or use an external file hosting website from which I can access files using an API.
If I should save locally, how do I do that on MeteorJS? What packages or methods of doing so would you recommend?
Storing files on your server locally is possible, you would have to store them on a special folder and serve its content using Apache or Nginx, however I don't think it's a good idea because you're going to waste your application server resources on a task that is far better done by external storage services (Google Cloud Storage, Amazon S3, etc...).
You could even store files in MongoDB but it's even worse because they won't be easily cacheable and somewhat inefficient and unscalable.
The most elegant way is probably to upload your files directly from the end user client to the external storage service servers, without even passing via your Meteor application server. The client will only send the stored files URL to your Meteor server to persist them in MongoDB. External storage services have the benefit to offer cheap pricing on Gb/month and provide high disponibility, replication on multiple servers, etc...
There is a Meteor package that implements this workflow, I haven't personally tested it but I'm pretty sure this is reliable material and I'll give it a try.
https://github.com/CulturalMe/meteor-slingshot
The configuration may be a bit hard to get it right the first time but this is definitely the way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With