Skip to main content

Change publicID based on upload file name

Comments

1 comment

  • Stephen Doyle

    Hi Marcel,

    I'm afraid it isn't possible to use the preBatch method in this way - it provides a hook to allow you to perform your application's own logic on the files before they're uploaded, but you can't set the public_id in the way you're describing here.

    For the use-case you've mentioned, I would recommend one of the following methods instead:

    • Use tags or context values on the upload to identify the user who uploaded the file
    • Accept the file from the user in javascript directly, then call the API using your own code to specify the public_id, folder, etc
    • In conjunction with tags or context as above, or via logging the Upload Widget response yourself, have us notify your server-side code when the file upload completes, and have some server-side code copy or rename the image to the required path:  https://cloudinary.com/documentation/upload_images#notifications_and_asynchronous_transformations`

    Please take a look and see if any of those options would work for you; I'd be happy to explain in more detail if you can let me know some more about your current workflow and which option above most closely matches it.

    Regards,

    Stephen

    0

Post is closed for comments.