UPDATE: a new and much more advanced API was recently introduced to support generating zipped archives and bulk downloading your content. For more information see: generate_archive documentation and the complementary blog post.
From this point forward, documentation is outdated and API is deprecated.
When generating a ZIP file using the multi()
API method, the default behavior is to preserve the original folders hierarchy of the collected files inside the generated ZIP.
Cloudinary, now supports the flatten
flag (fl_flatten
for URLs) designated to override this behavior. Once this parameter is set, Cloudinary will generate a flat ZIP, ignoring the files' original folders hierarchy. In case of duplicates, a 1/2/3/... suffix will be added to the file names.
Note that the parameter must be used both within the multi()
API call and the request URL.
For example (PHP):
\Cloudinary\Uploader::multi('logo', array("format"=>"zip", "flags" => "flatten"));
Will result with the following delivery URL:
http://res.cloudinary.com/<cloud-name>/image/multi/fl_flatten/v1439801634/logo.zip
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.