Comments (5)
Hey @jjdiaz, the Admin API and the Upload API authentications are performed differently. While upload API indeed consists of a signature parameter, the Admin API uses Basic Authentication so the SDK doesn't generate the signature similar to the Upload API methods.
In general, special characters in the public_id
should be encoded when making API requests, so can you please try and encode commas will be replaced with %2C
and let me know if that solves the issue for you?
from cloudinary_php.
Hi, Clodinaraz.
I had already tried using urlencode without success. Please check this code snippet:
try{
$publicId= "Advertisements/manolito,comas";
$encodedPublicId = urlencode($publicId);
$result = $this->api->uploadApi()->updateMetadata(['act_test' => 'any value'], [$publicId]);
dump($result);
}catch (\Exception $e){
dump($e);
}
The result is:
Invalid Signature 43fd0c90297c7b90718923e793c7deea447e928f. String to sign - 'metadata=act_test=34343422234&public_ids=Advertisements/manolito,comas×tamp=1655739683'.
Replacing
$result = $this->api->uploadApi()->updateMetadata(['act_test' => 'any value'], [$publicId]);
by
$result = $this->api->uploadApi()->updateMetadata(['act_test' => 'any value'], [$encodedPublicId ]);
No errors found but no asset affected. The dump($result) shows as follows:
]
storage: array:1 [
"public_ids" => []
]
public_ids is empty so no assets affected and no changes are made on the Cloudinary side.
Workarround:
I've rewriten the method signParameters on the class Cloudinary\Api\ApiUtils.php as follows:
public static function signParameters($parameters, $secret, $signatureAlgorithm = Utils::ALGO_SHA1)
{
$parameters = array_map('self::serializeSimpleApiParam', $parameters);
ksort($parameters);
$signatureContent = self::serializeQueryParams($parameters);
/** jjd-Bugfix: This replacement prevents invalid signature errors when there are commas inside public_id */
$signatureContent = str_replace("\,",",", $signatureContent);
return Utils::sign($signatureContent, $secret, false, $signatureAlgorithm);
}
I didn't get any errors and the asset was updated in Cloudinary BUT I think there are side effects that I'm evaluating now.
Best Regards,
from cloudinary_php.
Hi @jjdiaz,
The call for updateMetadata looks right, but since you get no error but not find any "public_ids". Please open a support ticket and provide me the cloud name and make the call and I can investigate from our log and let you know.
from cloudinary_php.
Hello @momoip
I just opened ticket #190154
from cloudinary_php.
Hi @jjdiaz
Closing this issue here. We will continue on the support ticket
from cloudinary_php.
Related Issues (20)
- PHP 8.1 support HOT 5
- Migrate from Travis to GitHub actions HOT 2
- Add PHPStan HOT 1
- Wrong CLOUDINARY_URL HOT 3
- Why does the response I'm getting not reflect the documentation's format? HOT 5
- Missing a way to easily request every asset type HOT 18
- Deprecated: fopen(): Passing null to parameter #3 ($use_include_path) of type bool is deprecated (php 8.1) HOT 1
- Update access mode method not available in SDK HOT 10
- [2.7.1] Why separate package and failure on composer-require-checker HOT 1
- Fatal Error on PHP 7.4 HOT 2
- Error using defaultvalues in class SetMetadataField HOT 1
- Incorrect URL generated when Public ID of MediaAsset ends with dot + 1-5 characters HOT 3
- ${var} -> {$var} for PHP 8.2 compatibility in version 1.x HOT 5
- Deprecations on PHP 8.2 HOT 1
- Call to undefined function GuzzleHttp\Promise\promise_for() HOT 3
- Get rid of `teapot-php/status-code` dependency HOT 9
- Drop Guzzle requirement and replace with any PSR-18 HttpClient
- Use named parameters instead of array in Version 3 HOT 1
- Class 'Cloudinary\ClassUtils' not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloudinary_php.