uploader.read returns an empty string

オープン
#175 コメント 0 件 リアクション 0 件 担当者 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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cloudinary/cloudinary_gem のほかの issue

cloudinary/cloudinary_gem の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。