To open S3 objects directly in the browser instead of downloading them, you'll need to make some adjustments to your setup. Here's how you can modify your PHP code and S3/CloudFront configuration to achieve this: 1. Set the correct Content-Type header for your S3 objects: Make sure your S3 objects have the appropriate Content-Type metadata set. For example, PDFs should have "application/pdf", images should have "image/jpeg" or "image/png", etc. 2. Update your CloudFront distribution: Ensure your CloudFront distribution is configured to forward the Content-Type header from S3 to the browser. 3. Modify your PHP code: Instead of using a direct link to the S3 object, you can create a PHP script that serves the file with the correct headers. Here's an example: ```php 'latest', 'region' => 'your-region', 'credentials' => [ 'key' => 'your-access-key-id', 'secret' => 'your-secret-access-key', ], ]); $bucket = 'your-bucket-name'; $key = 'path/to/your/file.pdf'; // The S3 object key try { // Get the S3 object $result = $s3->getObject([ 'Bucket' => $bucket, 'Key' => $key ]); // Set the appropriate headers header("Content-Type: {$result['ContentType']}"); header("Content-Length: {$result['ContentLength']}"); header('Content-Disposition: inline; filename="' . basename($key) . '"'); // Output the file contents echo $result['Body']; } catch (AwsException $e) { // Handle any errors echo "Error: " . $e->getMessage(); } ``` 4. Update your HTML links: Instead of linking directly to the S3 URL, link to your PHP script: ```html View File ``` 5. Create a view_file.php script: This script will handle the file serving: ```php