You can generate a signed URL for creating a ZIP file on the fly and on-demand with the download_archive_url
method of the Utils API. The ZIP file is created and streamed to your user only when the URL is accessed. The resulting ZIP file is not cached or stored in your Cloudinary account, so this option is best if only a single user downloads the resulting ZIP file and avoids waste if the URL is not accessed by the user.
For example (In python):
cloudinary.utils.download_zip_url(**options)
To flatten you can use the flatten_folders option: Determines whether to flatten all files to be in the root of the archive file (no sub-folders). Any folder information included in the public ID is stripped and a numeric counter is added to the file name in the case of a name conflict. Default:false
.
For example (In python): To generate a URL for downloading a zip file that contains the images with the following public_ids: dog, cat and lion and flatten the folders:
result = cloudinary.utils\
.download_zip_url
( public_ids = ["dog","cat","lion"],
resource_type = "image", flatten_foders=true)
For more information see: generate_archive documentation and the complementary blog post.
Comments
4 comments
while downloading zip with fl_flatten tag with duplicate images
suffix is adding after image extension like abc.jpg-2 . so images are displaying with unknown extensions. please add suffix before extensions !!!
Thank you for pointing this out.
This should be fixed by the beginning of next week.
UPDATE: Issue was resolved.
Hi Nadav,
I wrote a quick script on .net to download all images scaled down to 100px, I'm able to download the zip, but I cannot figure out where to put the this flatten flag, could you please shade some light on this?
Cloudinary cloudinary = new Cloudinary(account);
Transformation transform = new Transformation();
transform.Height(100);
transform.Crop("scale");
MultiParams parameters = new MultiParams("kiss");
parameters.Format = "zip";
parameters.Transformation = transform;
MultiResult result = cloudinary.Multi(parameters);
if (result.Uri != null)
{
string url = result.Uri.ToString();
Response.Write("" + url + "");
}
Hi Alex, our .NET libraries have not yet been updated with the flatten option.
Furthermore, we're currently working on a significant upgrade to these libraries including support of the new generate_archive API.
Please sign in to leave a comment.