document.write('
  1. <?php
  2.  
  3. // The file name that you have uploaded earlier
  4. // Change to your file name
  5. $object_key = \'yourimage.png\';
  6.  
  7. // S3 Bucket Name
  8. // Change to your bucket S3 bucket name
  9. $bucket = \'wordpressha\';
  10.  
  11. // S3 Endpoint
  12. // Change to your bucket S3 Endpoint URL
  13. $s3_endpoint = \'ap-southeast-mys1.oss.ips1cloud.com\';
  14.  
  15. // S3 Access and Secret Key
  16. // Change to your bucket S3 Access & Secret Key
  17. $access_key = \'5IRK7V7TVSV0B829WHAD\';
  18. $secret_key = \'I7BLtOZAsHdCDHMeyJ73QipBIPjLDCvWhIAzfynV\';
  19.  
  20. $expires = time() + 3600; // URL expiration time (1 hour from now)
  21. $method = \'GET\'; // HTTP method
  22.  
  23. // Create the string to sign
  24. $string_to_sign = "{$method}\\n\\n\\n{$expires}\\n/{$bucket}/{$object_key}";
  25.  
  26. // Create the signature
  27. $signature = base64_encode(hash_hmac(\'sha1\', $string_to_sign, $secret_key, true));
  28.  
  29. // Generate the presigned URL
  30. $presigned_url = "https://{$bucket}.{$s3_endpoint}/{$object_key}?AWSAccessKeyId={$access_key}&Expires={$expires}&Signature=" . urlencode($signature);
  31.  
  32. echo "Presigned URL: {$presigned_url}\\n";
');