Nested folders failing to upload in widget

Options
kannydennedy
kannydennedy Member Posts: 3
edited July 2023 in Developer APIs

I've set up signed uploads with my upload widget. When I drag a single folder into the uploader, everything works fine. When I drag a nested folder into the uploader, it fails with a lot of 'invalid signature' errors. I swear this was working before, I don't know what changed. I think before (a few days ago?) it was flattening the folders in the Cloudinary console, now the folders are getting added in the console as well.

On the backend I just have

const signature = cloudinary.utils.api_sign_request(

params_to_sign,

process.env.CLOUDINARY_API_SECRET

);


Tagged:

Comments

  • kannydennedy
    kannydennedy Member Posts: 3
    Options

    My frontend

    cloudinary.applyUploadWidget(

    document.getElementById("upload_widget_images"),

    {

    api_key: XXXXX,

    cloudName: XXXXX,

    upload_preset: XXXXX,

    sources: ["local", "dropbox"],

    uploadSignature: generateSignatureWithSocket,

    buttonCaption: "Upload assets",

    clientAllowedFormats: ["jpg", "jpeg", "png", "mp3", "wav"],

    styles: uploaderStyles,

    button_class: "uploader-button",

    max_files: 20000,

    // Downscale the image to 800px width / 500 height

    maxImageWidth: 800,

    maxImageHeight: 500,

    folder: XXXXX, // I've tried with and without this

    use_filename: true,

    },

    (error, result) => {}

    );

  • kannydennedy
    kannydennedy Member Posts: 3
    Options

    It seems that when nested or multiple folders are uploaded, the params_to_sign becomes an array of params to sign, which is probably not helping.



  • epasos
    epasos Member, Cloudinary Staff Posts: 23
    Options

    Hi @kannydennedy ,

    The upload widget has the `pre-Batch` validation feature where you can analyze and get the folder structure for the source file (see https://cloudinary.com/documentation/upload_widget#pre_batch_validation). And using the information, you can update the `folder` parameter to where your files will be uploaded in your Media Library account through the `prepareUploadParams` event (see https://cloudinary.com/documentation/upload_widget#prepare_upload_parameters). In the same event, the signature can be calculated as well.