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 摘要。