Rails 加载未保存在图像文件夹中的图标

发布于 2024-09-26 18:42:44 字数 79 浏览 0 评论 0原文

我想预览一下刚刚上传的图片。这些图片没有保存在公共文件夹中,因为它们不是公开的...

我该怎么做?

谢谢 马库斯

I wand to give a preview of the just uploaded pictures. These pictures are not saved in the public folder, as they are not public...

How can I do this?

Thanks
Markus

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

弄潮 2024-10-03 18:42:44

您需要创建一个控制器来发送文件( http://api.rubyonrails .org/classes/ActionController/Streaming.html#method-i-send_file )它。

class AvatarsController

  def show
    send_file my_avatar_path, :type => 'image/jpeg', :disposition => 'inline'
  end
end

在此控制器中,您可以添加所需的所有授权。

You need create a Controller to send_file ( http://api.rubyonrails.org/classes/ActionController/Streaming.html#method-i-send_file ) it.

class AvatarsController

  def show
    send_file my_avatar_path, :type => 'image/jpeg', :disposition => 'inline'
  end
end

In this controller you can add all authorization you want.

聊慰 2024-10-03 18:42:44

您可以:

1)创建指向图像的符号链接
公共文件夹?

2)如你所是
他们公开使用这些图像
确实应该在公众面前
文件夹 - 为什么它们目前没有?

You could:

1) Create symlink to the images in
the public folder?

2) As you are
using the images publicly, they
should really be in the public
folder - why are they currently not?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文