2016-06-23 2 views
2

Я пытаюсь получить/получить файлы, хранящиеся на AWS Glacier, используя PHP. Но я не могу найти способ сделать это.Как получить/получить файлы из AWS Glacier с помощью PHP?

То, что я хочу, это просто получить/извлечь из AWS Glacier с помощью PHP. Если у кого-нибудь есть представление об этом, пожалуйста, предложите мне.

Спасибо.

ответ

1

По example from github вы можете получить файл с помощью следующей

// Use the us-west-2 region and latest version of each client. 
$sharedConfig = [ 
    'region' => 'us-west-2', 
    'version' => 'latest' 
]; 

// Create an SDK class used to share configuration across clients. 
$sdk = new Aws\Sdk($sharedConfig); 

// Create an Amazon Glacier client using the shared configuration data. 
$client = $sdk-> createGlacier(); 

//Download our archive from Amazon to our server 
$result = $aws->getJobOutput(array(
    'vaultName' => '<YOUR VAULT>', //The name of the vault 
    'jobId' => 'XXXX' //supply the unique ID of the job that retrieved the archive 
)); 

$data = $result->get('body'); //Sets the file data to a variable 
$description = $result->get('archiveDescription'); //Sets file description to a variable 

//deletes the temp file on our server if it exists 
if(file_exists("files/temp")){ 
    unlink("files/temp"); 
} 

$filepath = "files/temp"; 
$fp = fopen($filepath, "w"); //creates a new file temp file on our web server 
fwrite($fp, $data); //write the data in our variable to our temp file 

//Your archive is now ready for download on your web server 

Вы можете просмотреть PHP Glacier ref documentation для получения более подробной информации

Смежные вопросы