I am trying to upload to cloudinary through php, I tried the following code from my localhost and upload is successful and I get the response as Cloudinary APIResponse object
$config = Configuration::instance();
$config->cloud->cloudName = 'cloudname';
$config->cloud->apiKey = 'apikey';
$config->cloud->apiSecret = 'secrethere';
$config->url->secure = true;
$cloudinary = new Cloudinary($config);
$resp = $cloudinary->uploadApi()->upload( './Broccoli.gif', ["use_filename" => TRUE, "unique_filename" => FALSE, "folder" => "mythumbs"] );
and the response is
Cloudinary\Api\ApiResponse Object
(
[rateLimitResetAt] =>
[rateLimitAllowed] => 0
[rateLimitRemaining] => 0
[headers] => Array
(
[Date] => Array
(
[0] => Sat, 28 May 2022 18:58:47 GMT
)
[Content-Type] => Array
(
[0] => application/json; charset=utf-8
)
[Transfer-Encoding] => Array
(
[0] => chunked
)
[Connection] => Array
(
[0] => keep-alive
)
[Vary] => Array
(
[0] => Accept-Encoding
)
[Status] => Array
(
[0] => 200 OK
)
[Cache-Control] => Array
(
[0] => max-age=0, private, must-revalidate
)
[X-XSS-Protection] => Array
(
[0] => 1; mode=block
)
[X-Request-Id] => Array
(
[0] => a57f3df3ad7ba508ac21009183adb527
)
[X-UA-Compatible] => Array
(
[0] => IE=Edge,chrome=1
)
[ETag] => Array
(
[0] => "38ba68cdf700d347e507b1f5e15176fe"
)
[Server] => Array
(
[0] => cloudinary
)
)
[storage:ArrayObject:private] => Array
(
[asset_id] => 68b431d7e07ffeca56af43062eb6da22
[public_id] => mythumbs/Broccoli
[version] => 1653764327
[version_id] => ba3190f6dc801e856e8056ac0e2a8be8
[signature] => 50974060aa15a82b8fa0e5ee6c49809d82c46189
[width] => 600
[height] => 600
[format] => gif
[resource_type] => image
[created_at] => 2022-05-28T18:58:47Z
[tags] => Array
(
)
[pages] => 1
[bytes] => 13349
[type] => upload
[etag] => fc64f57bcf6066b19f1b7d803298bc25
[placeholder] =>
[url] => http://res.cloudinary.com/hooshiyaa/cloudname/upload/v1653764327/mythumbs/Broccoli.gif
[secure_url] => https://res.cloudinary.com/cloudname/image/upload/v1653764327/mythumbs/Broccoli.gif
[folder] => mythumbs
[original_filename] => Broccoli
[api_key] =>
)
)
I couldn't find any example of how to read this response object on cloudinary documentation. I want to retrieve the secure url and store it in db.
It seems cloudinary ApiResponse class is an extension of PHP Arrayobject, so all the methods listed here works on the response object from cloudinary. OffestGet fetched me the secure url. Thank You.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.