2016-06-23 7 views
2

PHPを使用してAWS Glacierに保存されているファイルを取得/取得しようとしています。しかし、私はそうする方法を見つけることができません。PHPを使用してAWS Glacierからファイルを取得/取得する方法は?

私が欲しいのは、PHPを使用してAWS Glacierからフェッチ/取得するだけです。誰かがそれについて考えているなら、私に示唆してください。

ありがとうございました。

答えて

1

あなたが詳細

ため PHP Glacier ref documentationを確認することができ、次の

// 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 

を使用してファイルを検索することができexample from githubを1として