Cloudinary's Admin API supports the listing of resources older than a certain date by providing a start_at
parameter. This may be useful for certain workflows like deleting outdated/unused assets.
Values for this parameter should be provided in a Date & Time format. Below are a few examples:
PHP:(new DateTime(201505200730))->format(DateTime::ISO8601)
Rails:Time.new(2015,05,20,07,30)
Java:new java.util.Date()
NodeJS:new Date("May 20, 2015 07:30:00")
The following example using the Rails SDK will return up to 500 resources which were created earlier than May 20th, 2015:
Cloudinary::Api.resources(start_at: Time.new(2015,05,20), max_results: 500)
If you wish to list resources newer than a specific date, this is done by setting the direction
parameter to asc
, e.g.:
Cloudinary::Api.resources(start_at: Time.new(2015,05,20), direction: "asc", max_results: 500)
Note that pagination will be necessary to get the details of over 500 assets.
When there are additional resources to go through, 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 resources()
call for details of additional assets. For more information on this, please refer to this article.
Comments
2 comments
Is there a opposite of start_at? I want to list all the images that are created after a specific date?
This can be done by setting the `direction` parameter to `asc`, as mentioned above.
Please sign in to leave a comment.