{"error":{"message":"Upload preset must be specified when using unsigned upload"}}

GeertE
GeertE Member Posts: 4
edited November 27 in Developer APIs

"I am attempting to upload a file using multipart/form-data, but I keep encountering the error: 'Upload preset must be specified.' Despite this, the request body does include the upload_preset. I've double-checked, and the field appears to be correctly set, yet the error persists. What could be causing this issue?"

The body is:

Content-Disposition: form-data; name="file"; filename="example.jpg"
Content-Type: image/jpeg
/9j/4AAQSkZJRgABAQAAAQABAAD/4gv4SUNDX1BST0ZJTEUAAQEAAAvoAAAAAAIA
AABtbnRyUkdCIFhZWiAH2QADABsAFQAkAB9hY3NwAAAAAAAAAAAAAAAAAAAAAAAA
AAEAAAAAAAAAAAAA9tYAAQAAAADTLQAAAAAp+D3er/JVrnhC+uTKgzkNAAAAAAAA
........
fCCT5T5tJ5EiNDUGw3HvEtu+SMgdlUuzKMo1jZtRzLGOQ5VuYTjJIlhmyEKQS0EQ
ugggqOgkx1qpaXr6l7y3yz//2Q==
---------------------------123456789
Content-Disposition: form-data; name="upload_preset"
Content-Type: text/plain

my_preset_name
---------------------------123456789

Tagged:

Comments

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 172 admin

    Hi,

    Thank you for reaching out to Cloudinary! Looking briefly at the error, it looks like you're making an unauthenticated upload request which requires an upload_preset to be preset in the request body. Unsigned upload options are controlled by an upload preset, so in order to use this feature you first need to enable unsigned uploading from the Upload page of the Console Settings. An upload preset is used to define which upload options will be applied to assets that are uploaded unsigned with that preset specified. You can edit the preset at any point in time (or create additional upload presets), to define the parameters that will be used for all assets that are uploaded unsigned from user browsers or mobile applications. For more information on upload presets, see the upload preset guide.

    Using cURL to call directly to the Upload API endpoint will be the following:

    curl https://api.cloudinary.com/v1_1/demo/image/upload -X POST
    

    🧑‍🎓 Academy Training | 📖 Documentation | 📰 Blog

  • GeertE
    GeertE Member Posts: 4
    edited November 28

    Hi team,

    Thank you for looking into this! I’m aware of the upload preset and have already defined it, so that’s not the issue. Unfortunately, using cURL isn't a viable solution in my case because I'm uploading the image as a Base64 string. Even with a small image, I encounter a cURL error stating that the parameter value exceeds the allowed limits.

  • Tom
    Tom Member, Cloudinary Staff Posts: 112

    Hi @GeertE ,

    Thanks for replying.

    If you're still getting that error then it means the upload preset is not being set correctly in your upload request.

    I would recommend looking at our Postman example of making unsigned uploads: https://www.postman.com/cloudinaryteam/programmable-media/request/mbkq17c/upload-file-unsigned?tab=body .

    More on using our Postman collections: https://cloudinary.com/documentation/using_cloudinary_postman_collections#banner

    If you still get errors, please share your Postman collection.

    Please let me know if you have any other questions or queries.

    Kind Regards,

    Thomas

  • GeertE
    GeertE Member Posts: 4

    Hi Thomas,

    Thank you for helping me!

    How can I share my postman collection? Do you have an email address for me to share my collection?

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 172 admin

    Hi @GeertE,

    Thanks for replying.

    Did you look at our Postman collection and did it help you at all?

    If not then you can create a public workspace and send me the link, see https://learning.postman.com/docs/collaborating-in-postman/using-workspaces/public-workspaces/.

    Thanks,
    Thomas
    Developer Support Engineer
    Cloudinary


    🧑‍🎓 Academy Training | 📖 Documentation | 📰 Blog

  • GeertE
    GeertE Member Posts: 4

    Hi Thomas,

    I’ve sent you an invitation, where you'll find several Postman requests I forked from Cloudinary’s examples. The original Cloudinary requests work perfectly Unfortunatly, uploading a file from the server is not an option for me. In my case, the images are stored in a database, so I need to use the Base64 string option. The Upload File - Multipart (postman) request (in the collection I shared with you) is what I want to get working. but it returns an "Upload preset" error, even though I’ve included it in the request.

  • Tom
    Tom Member, Cloudinary Staff Posts: 112

    Hi @GeertE ,

    Thanks for replying.

    Where did you send the invite?

    You can always share it with us via https://support.cloudinary.com/hc/en-us/requests/new and reference this post.

    Kind Regards,

    Thomas