cloudinary / cloudinary_gem

Cloudinary GEM for Ruby on Rails integration
https://cloudinary.com
420 stars 285 forks source link

ActiveStorage::Attachment#download returns empty string #420

Closed manuelmeurer closed 4 years ago

manuelmeurer commented 4 years ago

I'm trying to download an attachment but only get an empty string:

> file
#<ActiveStorage::Attachment:0x00005609c9fc6718> {
             :id => 23,
           :name => "files",
    :record_type => "ContractTemplate",
      :record_id => 1,
        :blob_id => 28,
     :created_at => Wed, 29 Jul 2020 15:18:43 CEST +02:00
}

[3] Uplink PROD(main)> file.download
  Cloudinary Storage (18.5ms) Downloaded file from key: abc
""

It only happens with this one file AFAIK and it's a docx file. Maybe that is the problem?

I can see it in the Cloudinary media console and download it from there without problems. Also, downloading via the ActiveStorage blob URL (https://my.app/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBJUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--765be73bbb13e3825e0c04cfc0d18c68cf05478d/my-file.docx) works without a problem too, so it really seems to be that #download method that is the problem.

Issue Type (Can be multiple)

[ ] Build - Can’t install or import the SDK [ ] Performance - Performance issues [x] Behaviour - Functions aren’t working as expected (Such as generate URL) [ ] Documentation - Inconsistency between the docs and behaviour [ ] Other (Specify)

Environment and Libraries (fill in the version numbers)

Cloudinary Ruby SDK version - 1.17.0 Ruby Version - 2.7.1 Rails Version - 6.0.3.2 ActiveStorage - 6.0.3.2

d-mendoza commented 4 years ago

@manuelmeurer We are looking into your request. And we will update once we are able to reproduce it on our end.

manuelmeurer commented 4 years ago

@d-mendoza Thanks! Let me know if I can do anything to help.

d-mendoza commented 4 years ago

@manuelmeurer When I tried to download it, I get something like this:

Cloudinary Storage (138.0ms) Downloaded file from key: ypasifasuu5d5uz0dn1e5fzkwz5e => "\xFF\xD8\xFF\xE0\x00\x10JFIF\x00\x01\x01\x01\x00d\x00d\x00\x00\xFF\xDB\x00C\x00\x...

So it seems to be working. I wonder if you have something else that's conflicting with it or maybe the file is corrupted. Any change you also try it on another docx file?

egorslam commented 4 years ago

@d-mendoza I have the same issue with .download link for PDF files.