在sails.js 中上传后图像未立即显示 [英] Image not showing immediately after uploading in sails.js

查看:44
本文介绍了在sails.js 中上传后图像未立即显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我已将上传的图像存储到文件夹 ./assets/uploads.我正在使用 easyimage 和 imagemagick 来存储图像.

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!

推荐答案

这是完全正常的情况,因为 Sails 处理资产的方式.

It's a totally normal situation, because of the way Sails works with the assets.

事情是,在 sailslift 后,资产(包括目录结构和符号链接)从 ./assets 文件夹复制到 ./.tmp/public,可公开访问.

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.

因此,为了在上传后立即显示您的图片,您基本上需要将它们上传到 ./assets/uploads 而不是 ./.tmp/public/uploads.

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.

现在唯一的问题是 ./.tmp 文件夹在每次应用程序重新启动时都会被重写,并且将上传的内容存储在 ./tmp/... 中每次扬帆后将它们擦除.例如,这里的解决方案是将上传存储在 ./uploads 中,并使用一个符号链接 ./assets/uploads 指向 ../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.

这篇关于在sails.js 中上传后图像未立即显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆