cloudinary / cloudinary/cloudinary_gem

uploader.read returns an empty string

Đang mở
#175 0 bình luận 0 reaction 1 người được giao Được giao cho @d-mendoza Xem trên GitHub
question
Ngôn ngữ chính
Ruby
Star
420
Fork
285
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

``` ruby
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

``` ruby
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

``` ruby
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.

``` ruby
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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.