I need to let my users upload images. But I don't know where can I create my "uploads" folder and how have access to it in my view.
In SailsJS, we have a folder assets/images, but all images in it will be copied in the public folder .tmp, when we lift sails (with Grunt). So I can't create my folder in .tmp neither in asset/images.
Someone have a solution ? Thanks
Assuming you are on a Linux-based system, you can just create your uploads
folder in you project's root and symlink it from assets
folder:
mkdir uploads && cd assets && ln -s ../uploads
Once Sails is lifted all the files from the uploads folder will be accessible via http://your.host.com/uploads/filename.ext
, including the once you upload during runtime.
That said, for large applications in production with a lot of uploads it would make sense to upload files directly to Amazon S3 or something similar and serve them via a CDN.