Skip to content

Instantly share code, notes, and snippets.

@jeffotoni
Last active March 1, 2017 18:40
Show Gist options
  • Save jeffotoni/dbd44557cb7d27b14ec79bccec86e50f to your computer and use it in GitHub Desktop.
Save jeffotoni/dbd44557cb7d27b14ec79bccec86e50f to your computer and use it in GitHub Desktop.
<?php
/**
* @jeffotoni
* aws sdk download
* baixar o sdk pelo composer
* install composer curl -sS https://getcomposer.org/installer | php
* gerar o arquivo composer.json
* "require": {"aws/aws-sdk-php": "2.*"}
* composer update
*/
require_once 'vendor/autoload.php';
use \Aws\S3\S3Client;
$key = "xxxxxxxxx";
$secret = "xxxxxxxx";
$bucket = "nome do seu bucket";
$version = "latest";
$region = "us-east-1";
$dirfile_bucket = "diretorio/file.mp3"; ///diretorio no bucket com file ou somente file
$range = "bytes=0-3024"; //quantidade de bytes que deseja pegar, range de bytes
$filepath = "diretorio onde ira baixar o file"; # /tmp/file-part1.mp3
$credencials =
[
'version' => $version,
'region' => $region,
'credentials' =>
[
'key' => trim($key),
'secret' => trim($secret),
]
];
$s3 = \Aws\S3\S3Client::factory($credencials);
// Get a range of bytes from an object.
$command = $s3->getObject(array(
'Bucket' => $bucket,
'Key' => $dirfile_bucket,
'Range' => $range,
'SaveAs' => $filepath
));
print_r($command);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment