Class UrlSigner
Creates signed URLs for Amazon CloudFront resources.
Methods Summary
- __construct ( $keyPairId, $privateKey )
-
getSignedUrl ( string $url, string|integer|null $expires = null, string $policy = null )
Create a signed Amazon CloudFront URL.
Methods Details
__construct ( $keyPairId, $privateKey )
Parameters
$keyPairId | ID of the key pair | |
$privateKey | Path to the private key used for signing |
Exceptions
RuntimeException if the openssl extension is missing |
InvalidArgumentException if the private key cannot be found. |
string getSignedUrl ( string $url, string|integer|null $expires = null, string $policy = null )
Create a signed Amazon CloudFront URL.
Keep in mind that URLs meant for use in media/flash players may have
different requirements for URL formats (e.g. some require that the
extension be removed, some require the file name to be prefixed
- mp4:
Parameters
string | $url | URL to sign (can include query string string and wildcards) |
string|integer|null | $expires = null | UTC Unix timestamp used when signing with a canned policy. Not required when passing a custom $policy. |
string | $policy = null | JSON policy. Use this option when creating a signed URL for a custom policy. |
Returns
string The file URL with authentication parameters |
Exceptions
InvalidArgumentException if the URL provided is invalid |