Skip to main content

Listing all assets within a folder

Comments

32 comments

  • cuma elp

    is there any php sample for this?

    0
  • Nadav Ofir

    The following is the equivalent in PHP:

    $api->resources(array("type" => "upload", "prefix" => "my_folder/"));

    3
  • cuma elp

    i wish there's a thank u or vote button.
    anyway, thank u for your help. i'll try this later

    0
  • Chester Copperpot

    is there a way to get the transformed image urls for the photos in that folder?

    0
  • Nadav Ofir

    Chester, This will require writing a short script:
    First you will have to list all resources within the folder.
    Then, for every public ID, you will be able to list all of its transformed versions using the resource() method

    If you need any additional assistance, feel free to open a support ticket.

    0
  • Robin

    Hello can someone help me out.

    I'm new to Cloudinary and using the service for delivering image http url's for delivering to a webshop service. The will read them one time only to fill their databas.

    Can i make a list with all my uploaded pictures in Cloudinary and export or see the image url all together.

    I can now only get the links when i click them one by one.

    0
  • Nadav Ofir

    Exporting such a list requires using the Admin-API. It's on our roadmap to add UI support for this task as well.
    If you're having difficulties getting this done, feel free to open a support ticket and we'll be happy to assist.

    -1
  • Mark Gavagan

    SIMPLE: While in your media library, once you're in the right folder or have the right images displayed, select the one on the top-right, scroll down and (Mac) hold shift while selecting the last image in the group, and all in between are selected automatically.

    0
  • swapcase

    Sir , I can neither code in PHP nor in Node.js, is there any other way of achieving this? ANy ETA on the UI feature implementation?
    Its stopping my business deliverable and I would urgently need the list of image URLs in csv/text format.
    Is there any work around for this issue?

    -1
  • swapcase

    Or leave it, I dont have time and didnt get support from cloudinary so Ive found a workaround with zero coding efforts.
    Thanks :)

    -2
  • Nadav Ofir

    Hi dear users,

    While we don't yet have an ETA for this functionality, you can rest assure that we will update here as soon as this becomes available.

    0
  • Gex Tecnologia

    Can I list every file of a folder? I tried that way and returns only images:

    (In PHP)
    $api->resources(array("type" => "upload", "prefix" => "folder1/folder2/"));

    But i want that bring me images, videos and raw files at same time. It can be done?

    0
  • Nadav Ofir

    Hi, currently this kind of task requires making 3 separate API calls and then merging the results.

    0
  • Amol Bapat

    Thanks for this, for others, this response that api returns, is enough to get the list of URLs into any type of file by some coding. You just need to pick up the URLs from the response and insert into your DB and then do some coding to achieve what you need.

    0
  • Jake

    Here is how you use PHP to show all images in a folder....

    $api = new \Cloudinary\Api();
    $resources = ((array) $api->resources(["type" => "upload", "prefix" => "projects/test"])['resources']);
    foreach ($resources as $resource) {
    echo cl_image_tag($resource['public_id']);
    }

    0
  • vincent

    hi everyone, do you have any advices for ROR ? 

    0
  • Maor Gariv

    Hi Vincent,

    Thanks for reaching out.

     

    Sure:)

    This code in Rails will iterate and print all public_ids from the response  - 

     

    results = Cloudinary::Api.resources(type:"upload",prefix:"<PREFIX>")
    results['resources'].each {|resource| puts resource['public_id']}

     

    Hope it helps!

    0
  • Vineeth

    Hi,

    How to get the list of images in folder in Android?

    0
  • Martin Cazares

    In the Java API it seems like the "prefix" parameter is being ignored, I can't fetch by folder/prefix and after looking into the code I noticed that this is what the API has:

     

    public ApiResponse resource(String public_id, Map options) throws Exception {
    if (options == null) options = ObjectUtils.emptyMap();
    String resourceType = ObjectUtils.asString(options.get("resource_type"), "image");
    String type = ObjectUtils.asString(options.get("type"), "upload");

    ApiResponse response = callApi(HttpMethod.GET, Arrays.asList("resources", resourceType, type, public_id),
    ObjectUtils.only(options, "exif", "colors", "faces", "coordinates",
    "image_metadata", "pages", "phash", "max_results"), options);

    return response;
    }

    Notice that:

    ObjectUtils.only(options, "exif", "colors", "faces", "coordinates",
    "image_metadata", "pages", "phash", "max_results")

    Doesn't include prefix...

     

    Is there a version of the java API that includes it? I really need it...

     

    Thanks in Advance

    0
  • Marissa Masangcay

    Hi Martin,

    You want to use our 'resources' method instead of our 'resource' method. If you take a look at our Github you will see that "prefix" is included in our 'resources' method. :)

    https://github.com/cloudinary/cloudinary_java/blob/03913e9af1fd46616e4dde92e0acb0c0de586991/cloudinary-core/src/main/java/com/cloudinary/Api.java#L58-#L70

    So you should be able to make a java call like so:

    cloudinary.api().resources(ObjectUtils.asMap("prefix", "test/folder/", "type", "upload"));

    Hope this helps!

    0
  • Xadani

    How can I do this using jQuery Library?

    0
  • Daniel Mendoza

    Hi @Xadani,

    The use of Admin API should only be used on server-side SDKs. If it was used in jQuery, this would expose your api_secret which is not advised.

    If server-side is not available, another approach would be to use client-side resources lists but would require tagging each image with a tag (in this example tagging the image with the folder that it belongs to). Then you can make a URL request that will return all the images that have that particular tag (aka folder) and parse the JSON response. More info here: https://cloudinary.com/documentation/image_transformations#client_side_resource_lists

    Hope this helps!

    0
  • Tarun Chauhan

    I need ful list of data upload in my account . i am trying with $api->resources(array("type" => "upload", "prefix" => ""));  but  i will returm 10 records only 

    1
  • Yakir Perlin

    Hi, 

    If you want more than 10 results per call, you can set the max_results option. (Integer, default=10. maximum=500). 

    Note that when a listing request has more results to return than max_results, the next_cursor value is returned as part of the response. You can then specify this value as the next_cursor parameter of the following listing request.

     

    Please let me know if it works for you.

    Yakir

    0
  • Mohamed Abderrahmen

    Is there a way to retrieve images inside a specific folder without having other images in other subfolders of the folder specified using the API and without the Search being active.

    Remarks :
    I'm already aware of the prefix thing, that one retrieves images inside subfolders.
    I'm using an "Advanced plan" feature here the search is not active. I know that with the search it is possible to do so.
    I appreciate very much your help.

    0
  • Aditi Madan

    You can use Admin API to browse resources and specify in an if condition the folder name that you would want the resources to be listed.

    But this process will go through all your resources and put in a list the resources within the folder you specified.

    Thanks,
    Aditi

    0
  • Daria

    Hi! Is it possible to list all the images within a folder using Fetch API in js?

    0
  • Stephen Doyle

    Hi Daria,

    The way to list all resources in a folder is using the Admin API methods Itay mentioned at the top of this thread, but that's a signed API method that uses your account's API secret for authentication, so it's not suitable for use in client-side JS code.

    If you need to fetch a list of assets in the client-side, another option may be to use a client-side resource list, which is a JSON object containing the details of images tagged with a specified tag: https://cloudinary.com/documentation/advanced_url_delivery_options#client_side_resources

    If you add tags to your images corresponding to the folder path it would work in a similar way, and this is how our Product Gallery Widget loads images, based on them being tagged with a product ID or SKU

    Regards,
    Stephen

    0
  • il cortile degli artisti

    How can I achive this with angular 5.x library?

    0
  • Aditi Madan

    Hi,

    You can use the list by tag which is a client-side feature to get the list of resources. More information here: https://support.cloudinary.com/hc/en-us/articles/203189031-How-to-retrieve-a-list-of-all-resources-sharing-the-same-tag-

    You can select all the images inside the folder and add a tag, then use the list by tag to get the list of all the resources inside that folder.

    Regards,

    Aditi

    0

Please sign in to leave a comment.