uploader.read returns an empty string

未关闭
#175 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@d-mendoza 已经在做这个了。

开始于 2021年3月3日。

评估

这个 Issue 还没有评估数据。

描述

question

I use cloudinary 1.1.0 with carrierwave 0.10.0 in a rails 4.2.4 app to store PDFs.

I get the following bug

record.pdf.read # => ""

I digged a bit into the code base and realised that the Uploader's identifier was not the same as the Cloudinary::CarrierWave::CloudinaryFile's identifier

record.pdf.identifier # => v1444643650/foo.pdf
record.pdf.file.identifier # => image/upload/v1444643650/foo.pdf

Internally, pdf.read calls pdf.file.read which is defined as

def read(options={})
  parameters={:type=>self.storage_type, :resource_type=>self.resource_type}.merge(options)
  Cloudinary::Downloader.download(self.identifier, parameters)
end

Cloudinary::Downloader.download then gives Cloudinary::Utils.cloudinary_url the passed identifier to generate the URL to read data from.

But the generated URL is wrong when the identifier is pdf.file.identifer. I tried with the uploader's identifier and it worked.

Cloudinary::Utils.cloudinary_url pdf.identifier
# => http://res.cloudinary.com/cloud_name/image/upload/v1444643650/foo.pdf

Cloudinary::Utils.cloudinary_url pdf.file.identifier
# => http://res.cloudinary.com/cloud_name/image/upload/v1/image/upload/v1444643650/foo.pdf

Hope this helps to fix the bug

主要语言
Ruby
星标
420
派生
282
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudinary/cloudinary_gem 的其他 Issue

查看 cloudinary/cloudinary_gem 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。