Created
March 22, 2018 17:45
-
-
Save shirlymanor/8cd8b95e1132be19eb8cd5e7363828ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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