uploadcare / uploadcare-ruby

Ruby API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
MIT License
39 stars 28 forks source link

Signed URLs updates #134

Closed rsedykh closed 4 days ago

rsedykh commented 7 months ago

I want uploadcare-ruby to have the same signed URL capabilities as pyuploadcare. Correct me if this is something wrong to do (or already done, or requires to build something else).


Implement generating URL tokens for signed URLs

Currently, the lib allows for generating ACL tokens only. Akamai supports two type of tokens: ACL and URL. See https://github.com/akamai/EdgeAuth-Token-Python/blob/master/akamai/edgeauth/edgeauth.py for reference.

Allow to pass a UUID + params when generating signed URL (ACL)

Currently, the AkamaiSecureUrlBuilder class allows for signing a whole URL. In some cases, there's a need to generate a universal ACL token with wildcards. For example, we can specify an ACL as follows:

/{uuid}/*

and the token generated will be applicable to any variation of the file associated with the {uuid}. E.g., https://ucarecdn.com/{uuid}/-/resize/360x/-/format/auto/

See https://github.com/akamai/EdgeAuth-Token-Python/blob/master/akamai/edgeauth/edgeauth.py#L183 for reference.


You can use pyuploadcare implementation as a reference:

vipulnsward commented 4 days ago

This now works after recent changes around this:

Ex:

https://sectest.ucarecdn.com/548930f2-9c76-4e6f-ad11-26025c23a45d/-/rotate/90/-/crop/3410x2580/0,0/-/preview/3000x3000/?token=exp=1720261848~acl=/548930f2-9c76-4e6f-ad11-26025c23a45d/-/rotate/90/-/crop/3410x2580/0,0/-/preview/3000x3000/~hmac=9785b14fe02c8f543c6e386e0feb772935468ed02c347d7f4e274a2c0d1f7737