ruby-on-rails - Active Storage Permanent Image URL
问题描述
I'm creating a google product listing for a website built in Ruby on Rails. The website has multiple stores with their own front ends so they're wanting a Google Product Feed for each store.
The issue I'm having is if I use url_for(image) then I get the URL for the image on that store. But the way active storage works it's on a temporary URL that lasts 5 minutes by default. So the links wouldn't work on the feed by the it's been processed.
The images are hosted on an S3 bucket so I can get the service_url. But Google doesn't like having the images coming from a separate domain to the store. Is there a way to have a permanent clean url from the stores domain?
解决方案
我认为你所追求的并不容易。Active Storage 似乎不支持永久的、不会过期的 URL:将 S3 与 Active Storage 一起使用时出现“请求已过期”
根据您的设置,可能会有一个有用且(大部分)免破解的解决方法。就我而言,我在show
拥有我要链接到的文件的记录上设置了一个自定义操作:
redirect_to url_for(@record_name.file)
然后,像往常一样,在我的应用程序中使用路径助手进行记录show
操作,只是通过 expiring 呈现我想要的东西url_for
。
推荐阅读
- linux - Linux中的页面错误,如何解决?
- java - 缺少包“sun.java2d.cmm” - 有人知道我应该从哪里得到它吗?
- vba - Powerpoint VBA 中的发送键
- r - 如何在R中为ggplot中的矩形自动查找序列的开始和结束
- android - Firebase 云消息传递无法在后台运行
- video - 为什么 ffmpeg 将 FLV 转换为 h264 时会删除 SEI 消息?
- linux - lsyncd - 事件队列中的溢出 - 解决方案是调整 fs.inotify.max_queued_events
- sql - SQL将空日期与另一个日期进行比较
- java - while循环中的数学运算
- android - FireStore 数据库集从不调用 OnSuccessListener 或 OnFailureListener