cloudinary / cloudinary_js

Cloudinary JavaScript library
MIT License
328 stars 224 forks source link

Add signature param to transformation #196

Closed gilnoy closed 4 years ago

gilnoy commented 4 years ago

We need to have the ability to pass a signature param that will be added to the url.

We currently created a wrapper in our project to support this functionality since there are cases that client need to sign the image and send us back a signture which we need to add in the sdk url.

Thats our current implementation:

` client.url = wrap(client.url, (func, publicId, transformation, ...args) => { let modTransformation = transformation; let modSignature;

if (transformation && transformation.signature) { const { signature, ...restTransformation } = transformation; modSignature = signature; modTransformation = restTransformation; }

const url = func.call(client, publicId, modTransformation, ...args);

if (!modSignature) return url;

const rawTransformation = client.transformation_string(modTransformation); const pos = url.indexOf(rawTransformation); return [url.slice(0, pos), ${modSignature}/, url.slice(pos)].join(''); }); `

ghost commented 4 years ago

Added in version 2.8.0