Skip to content

Instantly share code, notes, and snippets.

@shirlymanor
Created March 22, 2018 17:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shirlymanor/8cd8b95e1132be19eb8cd5e7363828ff to your computer and use it in GitHub Desktop.
Save shirlymanor/8cd8b95e1132be19eb8cd5e7363828ff to your computer and use it in GitHub Desktop.
var cloudinary = require('cloudinary').v2;
cloudinary.config({
cloud_name: "<CLOUD NAME>",
api_key: "<API KEY>",
api_secret: "<API SECRET>"
});
var result = [];
var options = { type: "upload", max_results: 500, prefix: "<Name of the Folder>/" }; //Add you folder name + `/`
var sizefolder = 0
function listResources(next_cursor) {
if (next_cursor != null && next_cursor != 1)
options["next_cursor"] = next_cursor;
if (typeof next_cursor !== 'undefined' && next_cursor){
cloudinary.api.resources(options, function(error,response){
resources = response.resources;
result = result.concat(resources);
for(var res in resources)
{
myres = resources[res];
var mysize = myres.bytes;
var mypublicId = myres.public_id;
console.log(sizefolder);
sizefolder += mysize;
}
var more = response.next_cursor;
if (more)
listResources(more);
else
console.log("DONE" + sizefolder);
});
}
}
listResources(1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment