Skip to main content

Using Pre-Signed URL PHP with Stook

You can create pre-signed URLs for any Stook operation using the getCommand method. Then by createPresignedRequest () method, you can call these URLs.

Sample Code

CODE
1.  require 'vendor/autoload.php';  
2.  
3.  use Aws\S3\S3Client;  
4.  use Aws\S3\Exception\S3Exception;
5.  
6.  $bucket = "bucket";  
7.  $key = "mykey"; 
8.  
9.  //Create a S3Client  
10.  $s3 = new Aws\S3\S3Client([
11.     'endpoint' => 'https://customername.mncdn.com',
12.     'profile' => 'medianova',
13.     'version' => 'latest',
14.     'region' => 'us-east-1',
15.     'use_path_style_endpoint' => true
16.  ]);
17.  
18.  $cmd = $s3->getCommand('GetObject', [
19.     'Bucket' => $bucket,
20.     'Key' => $key,
21.  ]);
22.  $request = $s3->createPresignedRequest($cmd,'+20 minutes');
23.  
24.  $presignedUrl = (string) $request->getUri();  
25.  echo $presignedUrl;

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.