You are here

function hook_amazons3_url_info in AmazonS3 7

Allows other modules to change the format and options used when creating an external URL. For example the URL can be a URL directly to the file, or can be a URL to a torrent. In addition, it can be authenticated (time limited), and in that case a save-as can be forced.

Parameters

$local_path: The local filesystem path.

$info: Array of keyed elements:

  • 'download_type': either 'http' or 'torrent'.
  • 'https': either TRUE or FALSE.
  • 'torrent': (boolean) Causes use of an authenticated URL (time limited)
  • 'presigned_url_timeout': (boolean) Time in seconds before an authenticated URL will time out.
  • 'response': array of additional options as described at http://docs.amazonwebservices.com/AWSSDKforPHP/latest/index.html#m=Amazo... If you return anything other than an empty arrayhere, CloudFront support for these URLs will be disabled.

Return value

The modified array of configuration items.

1 invocation of hook_amazons3_url_info()
AmazonS3StreamWrapper::getExternalUrl in ./AmazonS3StreamWrapper.inc
Returns a web accessible URL for the resource.

File

./amazons3.api.php, line 35
This file contains no working PHP code; it exists to provide additional documentation for doxygen as well as to document hooks in the standard Drupal manner.

Code

function hook_amazons3_url_info($local_path, $info) {
  if ($local_path == 'myfile.jpg') {
    $info['presigned_url'] = TRUE;
    $info['presigned_url_timeout'] = 10;
  }
  $cache_time = 60 * 60 * 5;
  $info['response'] = array(
    'Cache-Control' => 'max-age=' . $cache_time . ', must-revalidate',
    'Expires' => gmdate('D, d M Y H:i:s', time() + $cache_time) . ' GMT',
  );
  return $info;
}