Skip to main content

Why do I get an "Invalid URL" message when trying to upload?



  • kye

    Binary_content is unclear

  • Roee Ben Ari

    Binary_content should contain a byte array buffer. Please see:

  • Kathy Smith

    I've also experienced this error when there were unicode characters in the file name (in this case an em-dash)

  • Romerike Jujutsu Klubb

    I get this error when using the Ruby gem.  Ruby StringIO does not have a `name` attribute.  What is the solition when using Ruby?

  • Aleksandar Kostadinov

    Hi @Romerike Jujutsu Klubb,

    As the error mentions this is due to the StringIO class not having this attribute. In general, you won't actually need to use this approach when uploading your images. Could you please share more details regarding where you are getting the files and how (sample code) you are currently attempting to upload them that lead you to use the above-mentioned approach?

  • Romerike Jujutsu Klubb

    Hi, thanks for the reply!

    Here is what I tried.  The `image` object is an ActiveRecord object, and `content_data_io` returns a StringIO object.  If I switch to `upload_large`, everything works fine, and this is an acceptable solution for me.  Going through the code, I see that `upload`and `upload_large` have slightly different checks on the `file` parameter.  I believe they should behave the same and that `upload_large` is correct and `upload` should be corrected.

    result = Cloudinary::Uploader.upload(
    resource_type: ? 'video' : 'image',
    public_id: "#{Rails.env}/images/#{}"


  • Aleksandar Kostadinov


    Thanks for providing these additional details.

    The upload and upload_large were updated a few versions ago to better standardise the handling as part of a different issue. -

    Essentially, your code with upload should work as the StringIO class has a read method which is what the upload method -

    Generally, for files below 100MB the upload method can be used but above that upload_large is recommended. Although I suspect in your example the file is less than 100MB in any case.

    Do you get any errors when using the code you shared? If you do, may I please ask you to share the error, and also which gem version you're using?


Please sign in to leave a comment.