PHP code example of reconnect / s3bundle

1. Go to this page and download the library: Download reconnect/s3bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

reconnect / s3bundle example snippets


use Reconnect\S3Bundle\Service\FlysystemS3Client;
// ...
private FlysystemS3Client $S3Client;

public function __construct(FlysystemS3Client $s3Adapter)
{
    $this->documentService = $S3Client;
}
// ...
// The  $objectKey is the key we used to identify the file in the bucket
$presignedUrl = $S3Client->getPresignedUrl($objectKey);

use Reconnect\S3Bundle\Service\FlysystemS3Client;
// ...
private FlysystemS3Client $S3Client;

public function __construct(FlysystemS3Client $s3Adapter)
{
    $this->documentService = $S3Client;
}
// ...
// Get a file as an instance of File
// This method returns the key of the uploaded file in the bucket
// This $key is a random UuidV4
$key = $S3Client->uploadFile($file);

use Reconnect\S3Bundle\Service\FlysystemS3Client;
// ...
private FlysystemS3Client $S3Client;

public function __construct(FlysystemS3Client $s3Adapter)
{
    $this->documentService = $S3Client;
}
// ...
// Get a file as an instance of UploadedFile
// This method returns the key of the uploaded thumbnail file in the bucket
// This $key is a random UuidV4
$thumbnailKey = $S3Client->generateThumbnail($file);