Resources Admin API not returning assets correctly
I'm simply trying to get a list of resources within a certain folder. Easy enough, right?
Cloudinary::Api.resources(prefix: "media/", type: "upload", max_results: 10)
Only returns 1 resource. I expect it to return 100+ (maxed out at 10)
{"resources"=>[{"asset_id"=>"7e8d06e7b670c9d83a43369011ddedd9", "public_id"=>"media/.../ryabjk8sgokhhgehxh8g", "format"=>"png", "version"=>1590615448, "resource_type"=>"image", "type"=>"upload", "placeholder"=>true, "created_at"=>"...", "bytes"=>0, "width"=>330, "height"=>65, "backup"=>true, "access_mode"=>"public", "url"=>"...", "secure_url"=>"..."}]}
But the media browser shows 100+, and to confirm, I did a search with a unique tag:
Cloudinary::Search.expression('session_recording').with_field('tags').max_results(100).next_cursor(next_cursor).execute
And the search returned 114 resources, all within that same media/ folder
{"total_count"=>114, "time"=>640, "next_cursor"=>"...", "resources"=>[{"public_id"=>"media/hew.../a6xzb5fydzqrttfntm1n", "folder"=>"media/hew.../Deploying_Azure_Stack", "filename"=>"a6xzb5fydzqrttfntm1n", "format"=>"mp4", "version"=>1591130263, "resource_type"=>"video", "type"=>"upload", "created_at"=>"...", "uploaded_at"=>"...", "bytes"=>53372255, "backup_bytes"=>53372255, "width"=>1280, "height"=>674, "aspect_ratio"=>1.89911, "pixels"=>862720, "duration"=>2791.72, "pages"=>0, "tags"=>["session_recording"], "url"=>"...", "secure_url"=>"...", "status"=>"active", "access_mode"=>"public", "access_control"=>nil, "etag"=>"...", "created_by"=>nil, "uploaded_by"=>nil}, ...
I expected both queries to return 114 resources, since they are all in that media/ folder. I don't understand why I'm only getting 1 image returned, and not all the videos. They were all set as type: upload.
I feel like I'm doing something wrong with the resources request, but I don't see what it is.
Thanks in advance for any help!
(If it matters, using Ruby gem 1.14.0)
-
Hi,
If the resource_type is not specified in the options of your request, the default value is 'image'.
It seems that your account has only 1 image with the prefix: "media/".
You can add parameter resource_type: "video" to list the videos.
0 -
Francis. Duh! It was definitely a stupidly-simple solution! But I really really really appreciate your help!
All the videos are being returned with:
Cloudinary::Api.resources(prefix: "media/", type: "upload", max_results: 10, resource_type: "video")
Thanks!
1
Post is closed for comments.
Comments
2 comments