In my application ,I have stored uploaded images to folder ./assets/uploads. I am using easyimage and imagemagick for storing the images.
In my application, after uploading the images, it should show the new uploaded image. But it is not displayed even if the page is refreshed. But when i do sails lift , the image is shown.
How to show image immediately after uploading the image? Thanks a lot!
It's a totally normal situation, because of the way Sails works with the assets.
The thing is that upon sails lift
the assets are being copied (including directory structure and symlinks) from ./assets
folder to ./.tmp/public
, which becomes publicly accessible.
So, in order to show your images immediately after upload, you, basically, need to upload them not to ./assets/uploads
but to ./.tmp/public/uploads
.
The only problem now is that the ./.tmp
folder is being rewritten each time your application restarts, and storing uploads in ./tmp/...
would make them erased after every sails lift
. The solution here would be storing uploads in, for example, ./uploads
and having a symlink ./assets/uploads
pointing to ../uploads
.
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