I am writing an application where I can upload images. Eventually I’ll upload them to some external service like s3, but for the moment I want to upload them to the filesystem where the meteor server is running.
The idea is to write them to some subfolders of the ‘public’ folder so that they can be displayed in the client easily.
Example the client could go to /products/.jpg and see the image of that product.
I first tried using packages for that but after looking for a long time I didn’t find any that were not deprecated, still actively maintained, and working fine with meteor 1.3 and/or react, so I decided to do it manually.
I got the client upload working, the server has a method that uses Node’s FS to actually write the file and it works fine. The problem is that the file gets saved in .meteor/local/build/programs/server directory by default.
My questions are:
1)How do i obtain the filepath to the project root and/or public folder so I can write there?
2)Is there a reason why I shouldn’t do it this way and be obliged to use something else (like mongo’s gridFS for example?)
3)Any other suggestions?