Image not showing immediately after uploading in sails.js

后端 未结 5 2177
轮回少年
轮回少年 2020-12-11 04:43

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 up

5条回答
  •  隐瞒了意图╮
    2020-12-11 05:00

    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.

提交回复
热议问题