How do I browse through all the resources in my account using the API?

Follow

Comments

9 comments

  • Avatar
    Debra Ornelas

    I don't understand what it is I need to get my phone with the right files and URL's it needs can you help me?

  • Avatar
    Roee Ben Ari

    Hi Debra, please contact us via a support ticket with more information regarding your use-case.

  • Avatar
    Susan lindroos

    How can I do this in node.js?

  • Avatar
    Roee Ben Ari

    Hi Susan, 

    You can do something like this:

    var result = [];
    var options = options = { type: "upload", max_results: 500 };

    function listResources(next_cursor) {
    if(next_cursor) {
    options["next_cursor"] = next_cursor;
    }
    cloudinary.api.resources(options, function(error,res){
    resources = res.resources;
    result = result.concat(resources);
    var more = res.next_cursor;
    listResources(more);
    });
    }

  • Avatar
    Susan lindroos

    Thank you! With few modifications I got it work nicely. :-)

  • Avatar
    Roee Ben Ari

    That's great! thanks for the update :)

  • Avatar
    Håkan Lindström

    How can I do this with php

  • Avatar
    Roee Ben Ari

    Hi Håkan,

    You can try something like this:

    $resources = array();
    $api = new \Cloudinary\Api();

    $result = $api->resources(
    $options
    );

    $resources = array_merge($resources, $result["resources"]);

    while (!empty($result) && array_key_exists("next_cursor", $result)) {
    $options['next_cursor'] = $result["next_cursor"];
    $result = $api->resources(
    $options
    );
    $resources = array_merge($resources, $result["resources"]);
    }

     

  • Avatar
    Håkan Lindström

    Thank you Roee Ben Ari

Please sign in to leave a comment.