PHP Classes

File: sample/aws-bucket-sample.php

Recommend this page to a friend!
  Classes of Leonardo Di Sarli   AWS Bucket PHP S3 Client   sample/aws-bucket-sample.php   Download  
File: sample/aws-bucket-sample.php
Role: Example script
Content type: text/plain
Description: Example script
Class: AWS Bucket PHP S3 Client
Perform common operations with Amazon S3
Author: By
Last change:
Date: 6 months ago
Size: 658 bytes
 

Contents

Class file image Download
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use
AwsBucket\AwsBucket;

$config = [
  
'credentials' => [
      
'key' => '', //you must put your aws iam key here
      
'secret' => '', //you must put your aws iam secret here
  
],
  
'version' => 'latest',
  
'region' => 'us-east-2',
];

$awsBucket = new AwsBucket($config);

$bucket = 'not-empty-test-bucket';
$content = 'this is your file content';
$name = 'sample';
$extension = 'txt';

$putFile = $awsBucket->putFile(
   
$bucket,
   
$content,
   
$name,
   
$extension
);
print_r($putFile);
echo
PHP_EOL;

sleep(3);

$listFiles = $awsBucket->listFiles(
   
$bucket
);
print_r($listFiles);