Uploading assets and keeping their original filenames

Follow

Comments

20 comments

  • Avatar
    cuma elp

    i think it not really keep the file name as it's current name** if** it has more period(s) other than it's file extension. I've test it today, the period will changed into underscore.

    for example : image.name.png=>** image_name**.png

    is there any solution to keep it as it is? it's real name with period(s) in it.

    0
    Comment actions Permalink
  • Avatar
    Nadav Ofir

    In Cloudinary we, indeed, replace periods with underscores as part of our naming conventions. Although, you can by-pass it by either explicitly supply the public_id, e.g., (in rails):

    Cloudinary::Uploader.upload(" my.image.jpg", :public_id => "my.image")

    Or, post-upload, rename the image using the Media-Library or the API, e.g., (in rails):

    Cloudinary::Uploader.rename("my_image","my.image")

    0
    Comment actions Permalink
  • Avatar
    cuma elp

    oh i see. so i supposed to specifically fill in the public_id with image file name

    0
    Comment actions Permalink
  • Avatar
    Nadav Ofir

    Did it work for you?

    If there is any thing else we can assist you with, please feel free to open a ticket:

    http://support.cloudinary.com/tickets/new

     

    0
    Comment actions Permalink
  • Avatar
    Itay Taragano

    UPDATE

    The system was just updated to support dot-included filenames, so use_filename will not replace dots with underscores.

    0
    Comment actions Permalink
  • Avatar
    ankit parsana

    Hi

    I am trying to upload the file keeping the original filename. Please check what I am doing wrong.

    echo cl_image_upload_tag('test', array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true),"folder" => "my_folder","unique_filename" => false));

    0
    Comment actions Permalink
  • Avatar
    Itay Taragano

    I couldn't find the use_filename parameter in the code you shared.

    Please try the following and let me know if this works for you:

    echo cl_image_upload_tag('test', array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true),"folder" => "my_folder","use_filename" => TRUE, "unique_filename" => FALSE));

    0
    Comment actions Permalink
  • Avatar
    Mirta Arambulo

    Hi Itay

    I am using this in my view on RoR
    <%= f.attachinary_file_field :file, as: :attachinary, cloudinary: {use_filename: true, unique_filename: false} %>

    but it doesn't work. It is always changing the document name. Could you help me please?

    0
    Comment actions Permalink
  • Avatar
    Mirta Arambulo

    For some reason the underscore characters are deleted from my comment.

    this is how i have
    http://screencast.com/t/PpWmDIgmQ7co

    0
    Comment actions Permalink
  • Avatar
    Maor Gariv

    Hi,

    Sorry for the very late reply, we have noticed that this request was left unattended. I see that your issue was handled through a support ticket with Itay:)

    0
    Comment actions Permalink
  • Avatar
    Luciano Montezzo

    Hi there, I have the same problem as Mirta reported...

    If you guys gave her the solution, could you please also answer it in here to help other people?

     

    Thx!

    0
    Comment actions Permalink
  • Avatar
    Yakir Perlin

    Hi Luciano, 

    Please try to reach us at support@cloudinary.com

    Best,

    Yaki

     

    0
    Comment actions Permalink
  • Avatar
    Torsten Peters

    Hello,

     

    new here.

    I havent found how to change the upload preset for image uploads from my computer, in order to keep the file names unchanged.

    "You can also specify those options in an Upload Preset, including an upload preset which will be used when you upload files using our Upload Widget or our Media Library interface. For an example of this, please see our Upload Preset Configuration article."

    (That article is now a video created 8 months ago and does not deal with that anymore, I believe

    Where/how do I have to add use_filename: true

    0
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    Hi Torsten,

    To change this value in your Upload Preset go to your settings (at the top right) => Click on Upload => Click on "edit" in the desired upload preset => Click on the toggle button in "Use filename or externally defined Public ID" to make it "true".

    If you have any more questions please let us know.

    Thanks,

    Tamara

    0
    Comment actions Permalink
  • Avatar
    Hoopersclub

    Hi, I've turned "Use filename or externally defined Public ID" to "On", and "Unique Filename" to "Off" but I'm still getting a random filename when I upload via AppSmith.

    Any idea what I might be doing wrong?

    0
    Comment actions Permalink
  • Avatar
    Aleksandar Kostadinov

    Hi @Hoopersclub,

    May I please ask you to share a public_id of an asset that you've uploaded which has the random characters appended at the end? We can check the logs on our side and confirm what lead to this.

    0
    Comment actions Permalink
  • Avatar
    Hoopersclub

    Hi @aleksandar, thanks for helping out. With some debugging on AppSmith end I figured out that for unsigned upload presets I had to pass public_id inside the parameters. I hadn't figured it out prior to this. Thanks anyway. Working ok! 

    0
    Comment actions Permalink
  • Avatar
    Aleksandar Kostadinov

    Hi @Hoopersclub - no worries at all - glad you resolved that!

    0
    Comment actions Permalink
  • Avatar
    Manzoni Fausto

    Hi,
    what is the correct regular expression to apply to a string to obtain the exact public_id, using use_filename?

    I need to check if a file already exsists, but I need to know the final format of public_id.

    ex: "this is (my file) name.mp3" => "this_is_my_file_name.mp3"

    0
    Comment actions Permalink
  • Avatar
    Sreenath Kalahasti

    Hi @ManzoniFausto,

    Thanks for reaching out.

    At the time of upload:
    If you have set public_id value, then your public_id will have the value you set in this field. Please check the documentation for more information: Upload API
    If you have set use_filename as true and unique_filename as false, then your public_id will be the same as file name.
    If you have set use_filename as true and unique_filename as true, then your public_id will have random characters at the end of it.
    If you have set use_filename as false and unique_filename as true, then your public_id will have random characters.
    If you have set use_filename as false and unique_filename as false, then your public_id will have random characters.

    Please refer to our Search API documentation in order for you to search by specifying the public_id based on the above conditions(whichever you chose to upload the file).

    Alternatively, you can use our Admin API GetResources API call to fetch the list of public_ids in your case and figure out the pattern.

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

    Best regards,
    Sreenath

    0
    Comment actions Permalink

Please sign in to leave a comment.