public function sync() { $transfer = new Transfer($this->client, $this->source, $this->destination, ['debug' => true]); $transfer->transfer(); }
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); }