Skip to main content

Missing public ids error when using download_zip_url with raw files

Comments

4 comments

  • Francis Tagbo

    Hi Jacin,

    Yes, the .3DL file was uploaded as a raw file. Hence, the file type should be included in the public id.

    Could you please try: 

    public_ids: ["rdhkeoccu8on9ahn0jk1.3DL"]

    Please let me know how it goes.

    0
  • Jacinto Fleta

    Hello Francis, it works.

     

    Thank you so much for your help!

    0
  • Francois Roy

    Hi Everyone,

    I have a very similar problerm (same error) when trying to generate a download URL for some audio files :
    The assets are wav files and residing in different folders/subfolders.

    The returned URL never works, with the most common error being :

    {"error":{"message":"Missing public_ids: share/librairie/chill/Emile_-_Tavel_ppx4a1.wav,share/librairie/chill/Charles_-_Pure_rentwm.wav,share/librairie/atmospheric/Francois_-_Fragance_vsd1xl.wav"}}

    This error correspond to this log where i list the public_ids and returned URL :

    Generate Zip download URL for share/librairie/chill/Emile_-_Tavel_ppx4a1.wav,share/librairie/chill/Charles_-_Pure_rentwm.wav,share/librairie/atmospheric/Francois_-_Fragance_vsd1xl.wav :
    https://api.cloudinary.com/v1_1/x-track/video/generate_archive?mode=download&public_ids%5B%5D=share%2Flibrairie%2Fchill%2FEmile_-_Tavel_ppx4a1.wav%2Cshare%2Flibrairie%2Fchill%2FCharles_-_Pure_rentwm.wav%2Cshare%2Flibrairie%2Fatmospheric%2FFrancois_-_Fragance_vsd1xl.wav&target_format=zip&timestamp=1623855345&use_original_filename=1&signature=dd2590506ca6c624041d4f05652419a79741cd8d&api_key=225998376837194

     

    My source code to retrieve the download URL is this one :

     

    /**
    * Return a calculated link to download a zip archive
    * containing the selected assets
    * @param{Array<String>}public_ids
    * @param{String}format to convert each asset
    * @returns{String}
    */
    export const getZipDownloadUrl = (public_ids, format = "wav") => {
    try {
    // Add the request format to the end of the public_id
    public_ids = public_ids.map((id) =>`${id}.${format}`).join(",");
    const downloadUrl = cloudinary.utils.download_zip_url({
    public_ids,
    resource_type:"video",
    use_original_filename:true
    });

    console.log(`Generate Zip download URL for ${public_ids} : ${downloadUrl}`);
    return downloadUrl;
    } catch (err) {
    console.error(err);
    throw new ApiError(500, err.message);
    }
    };



    0
  • Francois Roy

    With the great Cloudinary support, i was able to make my piece of code working, so here is the solution :

    • Audio files must not add the format to the public_id but instead keep the `resource_type: "video"`
    • To convert this audio files to other format, you must use the `transformation` parameter.

    With all that said, here is the working snippet :

    /**
    * Return a calculated link to download a zip archive
    * containing the selected assets
    * @param{Array<String>}public_ids
    * @param{String}format to convert each asset
    * @returns{String}
    */
    export const getZipDownloadUrl = (public_ids, format = "wav") => {
    try {
    return cloudinary.utils.download_zip_url({
    public_ids,
    resource_type:"video",
    use_original_filename:true,
    target_public_id:`download-${newDate().toISOString().substr(0, 19).replace(/[^0-9]/g, "-")}`,
    transformations:`f_${format}`
    });
    } catch (err) {
    console.error(err);
    throw new ApiError(500, err.message);
    }
    };

     

    1

Post is closed for comments.