コード例 #1
0
 public function sync()
 {
     $transfer = new Transfer($this->client, $this->source, $this->destination, ['debug' => true]);
     $transfer->transfer();
 }
コード例 #2
0
ファイル: StorageService.php プロジェクト: ravenhaus/cloud
 public function freeze(Package $package)
 {
     $manager = $this->doctrine->getManager();
     $archive = $this->temporalDir . '/archive-' . $package->getCode() . '.zip';
     $zip = new ZipArchive();
     $zip->open($archive, ZipArchive::CREATE);
     $tempDir = $this->temporalDir . '/glacier-' . $package->getCode();
     if (!file_exists($tempDir)) {
         mkdir($tempDir);
     }
     // Download Files
     foreach ($package->getFiles() as $file) {
         $src = 's3://' . $this->bucket . '/' . $package->getCode() . '/' . $file->getHash();
         $transfer = new \Aws\S3\Transfer($this->s3Client, $src, $tempDir);
         $transfer->transfer();
         $zip->addFile($tempDir . '/' . $file->getName(), $file->getName());
     }
     // Create Zip and Delete Downloaded File
     $zip->close();
     foreach ($package->getFiles() as $file) {
         unlink($tempDir . '/' . $file->getName());
         rmdir($tempDir);
     }
     // Initiate Glacier
     // Flag and Finish
     $package->setFrozen(Package::FROZEN);
     $manager->flush($package);
 }