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

Follow

Comments

16 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

  • Avatar
    Susan Lindroos

    How can I do it with .NET? There is many examples of uploding pictures but not how to do f.ex. listing

  • Avatar
    Susan Lindroos

    I managed to do this in .NET but now that I would like to make listing according to given tag/tags I end up with problems. I can retrieve data but only 10 pics at the time and I'm talking about more than 1000 pictures/query. How can I increase that amount to 500?

    I'm using Visual Studio 2017 with cloudinarydotnet -package.

    My function call is getResult = cloudinary.ListResourcesByTag(TxtBxTag.Text, options.NextCursor).

    Your documentation says that I can use max_result as parameter but I don't know how because definition of the function says

    Public Function ListResourcesByTag(tag As String, Optional nextCursor As String = Nothing) As ListResourcesResult

     

  • Avatar
    Yakir Perlin

    Hi, 

    Try to use this code:

    cloudinary.ListResources(new ListResourcesByTagParams()
                    {
                        MaxResults = 500,
                        Tag = "tag"
                    }); 

    Please let me know if it works for you.

    Best, Yakir

     

  • Avatar
    Susan Lindroos

    It doesn't let me use ListResourcesByTagParams(). Your definition says

    Public Function ListResources(parameters As ListResourcesParams) As ListResourcesResult

  • Avatar
    Yakir Perlin

    Hi Susan, 

    I'm sorry for the late response.

    Could you please elaborate on the error you received while using this code?

    The code I attached earlier in my response works for me.

    Best,

    Yakir

  • Avatar
    Olaegbe Samuel

    Hi, 

    Please I need the FULL php example to fetch my files from the cloud.

    The above example seems to be incomplete.

     

    I have tried it and I get the following error: 

    Fatal error: Uncaught Error: Class 'Cloudinary\Api\Response' not found in C:\xampp\htdocs\libra_gold\src\Api.php:540 Stack trace: #0 C:\xampp\htdocs\libra_gold\src\Api.php(54): Cloudinary\Api->call_api('get', Array, Array, NULL) #1 C:\xampp\htdocs\libra_gold\drive.php(37): Cloudinary\Api->resources(NULL) #2 {main} thrown in C:\xampp\htdocs\libra_gold\src\Api.php on line 540

  • Avatar
    Aditi Madan

    Hi Olaegbe,

    It looks like this is missing Api.php file. Please make sure you have included all the required PHP files in your project.

    You can download them from here: https://github.com/cloudinary/cloudinary_php/tree/master/src

    If you still experience issue then please raise a support ticket here: https://support.cloudinary.com/hc/en-us/requests/new and attach the zipped up project and we will be happy to take a look at it.

    Thanks,

    Aditi

Please sign in to leave a comment.