Gem carrierwave-aliyun 可以生成 oss 智能媒体链接吗

txbleehom · September 05, 2022 · Last by txbleehom replied at September 07, 2022 · 260 hits

使用 carrierwave-aliyun 生成下载链接没问题,但是现在需要使用 oss 的智能媒体服务在线预览文件,按照文档要求加了对应的参数就是不对,这种是不是不能用 carrierwave-aliyun,看 gem 包好像只实现了缩略图的功能

下载链接(https://xxx.oss-cn-shanghai.aliyuncs.com/attachments/demo.xlsx?x-oss-process=imm%2Fpreviewdoc%2Ccopy_1&Expires=1662347160&OSSAccessKeyId=xxxx&Signature=xxx)加了这个参数结果不对提示如下

https://github.com/huacnlee/carrierwave-aliyun#%E9%98%BF%E9%87%8C%E4%BA%91-oss-%E5%9B%BE%E7%89%87%E7%BC%A9%E7%95%A5%E5%9B%BE--about-the-image-thumb-service-for-alicloud-oss

file.url(thumb: '?x-oss-process=image/resize,h_100')

这个方法试过了没?

x-oss-process 这个参数,可以靠 url 函数的 thumb 参数来传递的,x-oss-process 相传什么随意。

不过有个点需要注意,carrierwave-aliyun 最初的设计是用于公开文件的场景,所以对私密 OSS Bucket 需要签名的场景不一定覆盖到位,你可能得试试。

不行的话,你可以换成 activestorage-aliyun,这个受 ActiveStorage 影响,私密、公开文件的支持都较好。

Reply to huacnlee
file.url(thumb: '?x-oss-process=image/resize,h_100')

这个开始就试过,换成?x-oss-process=imm/previewdoc,copy_1 文档也当缩略图生成了,点击链接就是下载下来一个无效的文件,那我再试试 activestorage-aliyun 看下,谢谢你的建议

You need to Sign in before reply, if you don't have an account, please Sign up first.