Ruby on rails: cloudinary gem Cloudinary::Utils.private_download_url

Comments

13 comments

  • Avatar
    Tamara Yulevich

    Hi,

    Thanks for reaching out.

    I can think of two reasons why you got this error:

    1) We don't support applying transformations on raw files. If you are trying to convert a .doc, or txt file to CSV - you can do that using the 'Aspose' add-on.

    2) The extension of the public id you provided wasn't CSV.

    Hope this helps, please let me know if you have any further questions.

    Best regards,
    Tamara

     

    0
    Comment actions Permalink
  • Avatar
    platinum job

    Hi Tamara,

    The public_id that I provided is not a real public id its just a example.
    I uploaded file with csv extension with this command

    Cloudinary::Uploader.upload('file.path', public_id: 'public_id', folder: 'bucket', :resource_type => :raw, :type=>'private')



    and now I just want to download it as it is (csv no transformations or conversion) with this command

    Cloudinary::Utils.private_download_url(public_id, 'csv', :resource_type => :raw, :expires_at=>FILE_EXPIRE_DURATION, :attachment=>true)


    however when you try to download that file with generated url it throws following error

    {"error":{"message":"Invalid extension in transformation: csv"}}

    It worked like charm before for months but suddenly it stopped working we did not change any codes.

    0
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    Hi, 

    Please take a look at this thread. I believe the following should work:

    Cloudinary::Utils.private_download_url("x.csv", :csv, resource_type: :raw)
    

    Please let me know if it does?

    Thanks,

    Tamara.

    0
    Comment actions Permalink
  • Avatar
    platinum job

    Hi, 
    Solutions on thread does not work for us.

    url = Cloudinary::Utils.private_download_url(public_id, format, resource_type: :raw)
    download = Cloudinary::Downloader.download(url)


    Also we want to download our files as an attachment (just download file not to view) 

    Cloudinary::Utils.private_download_url("x.csv", :csv, resource_type: :raw)

    when you generate a image URL with the upper command (that you suggested) and browse to the url it opens on browser tab, we don't want that and when if it is non image file the file name changes to 'download.csv' not the original file name that we uploaded.


    The probem we are having is when downloading non image files (csv, xlsx, doc etc..) that generated with following command

    Cloudinary::Utils.private_download_url(public_id, 'csv', :resource_type => :raw, :expires_at=>FILE_EXPIRE_DURATION, :attachment=>true)

    WITH ':attachment=>true' option is not working.
    It used to work before now it is not working.


    (Actual file uploading code

    Cloudinary::Uploader.upload("#{file.path}", public_id: identifier, folder: ROOM_FILE_BUCKET, :resource_type => :raw, :type=>'private', :filename_override=> original_filename)
    )
    0
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    Hi, 

    I'm checking this internally and will update here as soon as I get an answer. 

    Thanks, 

    Tamara

    0
    Comment actions Permalink
  • Avatar
    platinum job

    Hello,

    Any updates on this thread? 

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    Hi, 

    I did manage to reproduce the issue you are describing here (I got the same error), but the file was downloaded to my computer as expected. I escalated the issue to our SDK team and it's being reviewed. 

    Do you just get the error or is it not working? is the file downloaded as expected? Is the request sent as expected (Network arguments compared to our documentation)?

    I'm asking these questions because the backend code did not change. Since you are not reporting that this happened due to a new version, it sounds like something in the request might be invalid.

    Thanks,

    Tamara

     

    0
    Comment actions Permalink
  • Avatar
    platinum job

    Hi, 

    We are still getting the error and file is not being downloaded for extensions like csv, xlsx, doc..etc. However for other extensions such as jpg, png, pdf ..etc(image type of files) everything works normal.

    Thanks,
    Platinum job

    0
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    Hi,

    Could you please check if the request sent as expected (Network arguments compared to our documentation)?

    Thanks,

    Tamara

    0
    Comment actions Permalink
  • Avatar
    platinum job

    Yes we are using Ruby on Rails Cloudinary gem methods just as the documentation written. Please check the code that we have written below.

    Actual written file uploading code:

    Cloudinary::Uploader.upload("#{file.path}", public_id: identifier, folder: ROOM_FILE_BUCKET, :resource_type => :raw, :type=>'private', :filename_override=> original_filename)
    :filename_override=> original_filename

    We are setting filename_override option for downloading file with filename just as uploaded.

    For example if you upload test_name.csv then downloaded file will be test_name.csv not as name overridden with download.csv

    Actual written file download url generating code:

    Cloudinary::Utils.private_download_url(public_id, 'csv', :resource_type => :raw, :expires_at=>FILE_EXPIRE_DURATION, :attachment=>true)


    With attachment: :true option uploaded file will not be displayed on the browser tab but to be downloaded directly. 

    Just like we before said everything use to work with upper codes and suddenly it stopped working. Maybe there were some updates on API or some code tweaks that made it not to work. (We are using chrome browser)

    Now we are still getting the error and file is not being downloaded for extensions like csv, xlsx, doc..etc.

    {"error":{"message":"Invalid extension in transformation: csv"}}

    Is there some kind of workaround or maybe code changes that we should do? We need to fix this ASAP.

    0
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    Hi,

    Thank you for the detailed explanation.

    I have opened an internal ticket and will update here as soon as I hear back from the team. 

    Thanks,

    Tamara

    0
    Comment actions Permalink
  • Avatar
    platinum job

    Hello,

    Any updates on this thread? When this will be fixed? If there is no exact date then maybe we should look other workarounds.

    Thanks

    1
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    Hi, 

    This bug is in the process and will be fixed in the near future. I'll update here as soon as that happens.

    For now, you can use the URL as is, for example: 

    http://res.cloudinary.com/your-cloud-name/raw/upload/fl_attachment/file-name.csv

    Or if it's private:

    http://res.cloudinary.com/your-cloud-name/raw/private/s--lYYd_haF--/fl_attachment/file-name.csv

    Hope this helps

    Best,

    Tamara

    0
    Comment actions Permalink

Please sign in to leave a comment.