Singed widget uploads
Hello,
Thank you for the great product.
Unfortunately I've spent days trying to get signed uploads to work via the widget upload in my PHP application, to no avail.
When I use the following, as per your documentation:
\Cloudinary::api_sign_request($params_to_sign, $api_secret);
This breaks my application because the "api_sign_request" method is not found. I've imported the Cloudinary PHP package via Composer. Are the docs outdated, or am I doing something wrong?
Would it be possible to get a complete working example (JS and PHP code) that works?
Also, the link applyUploadWidget (https://cloudinary.com/documentation/upload_widget_reference#applyUploadWidget) on this page https://cloudinary.com/documentation/upload_widget#prepare_upload_parameters is wrong. It should be https://cloudinary.com/documentation/upload_widget_reference#applyuploadwidget .
Thanks for your help.
-
Hi Vukica,
Is there a reason you don't want to expire? If signature doesn't expire, then it would defeat the purpose of having a signed upload and unsigned upload should suffice for this scenario.
However to answer to your question, `api_sign_request` is PHPv1 method, while PHPv2, you may want to use `signParameters`.
Please check the following documentation for more info.Thanks,
Erwin Lukas -
Hi Erwin,
As per your documentation page: https://cloudinary.com/documentation/upload_widget#signed_uploads , upload signature type for signed uploads can be either string or function. With string type, the signature is generated on page load, meaning that it will expire if the page is open for long (if I understood correctly). With the function type, the signature is generated once the visitor uploads an image, so there is no danger of the signature expiring and the user having to refresh the page.
Thanks for the "signParameters" hint. I finally managed to get everything to work.
The docs that led me to the deprecated "api_sign_request" method stated that they refer the PHP SDK v2: https://cloudinary.com/documentation/php_integration . I highly recommend you guys correct these mistakes in order to save your customers' time. Adding the upload widget took me a week to figure out.
-
Hi Vukica,
I was also facing the same issue, but thanks for sharing the right solution it really helps me. Also I've read the guide which you shared link here, confusion is clear now.
Please sign in to leave a comment.
Comments
6 comments