Exemplo n.º 1
0
 private function createUploadPromise()
 {
     // Creates an iterator that yields promises for either upload or
     // multipart upload operations for each file in the source directory.
     $files = Aws\recursive_dir_iterator($this->source['path']);
     // Filter out directories.
     $files = \Aws\filter($files, function ($file) {
         return !is_dir($file);
     });
     // Map each file into a promise that performs the actual transfer.
     $files = \Aws\map($files, function ($file) {
         return filesize($file) >= $this->mupThreshold ? $this->uploadMultipart($file) : $this->upload($file);
     });
     // Create an EachPromise, that will concurrently handle the upload
     // operations' yielded promises from the iterator.
     return Promise\each_limit_all($files, $this->concurrency);
 }
Exemplo n.º 2
0
 /** @return Iterator */
 private function getDownloadsIterator()
 {
     if (is_string($this->source)) {
         $listArgs = $this->getS3Args($this->sourceMetadata['path']);
         if (isset($listArgs['Key'])) {
             $listArgs['Prefix'] = $listArgs['Key'] . '/';
             unset($listArgs['Key']);
         }
         $files = $this->client->getPaginator('ListObjects', $listArgs)->search('Contents[].Key');
         $files = Aws\map($files, function ($key) use($listArgs) {
             return "s3://{$listArgs['Bucket']}/{$key}";
         });
         return Aws\filter($files, function ($key) {
             return substr($key, -1, 1) !== '/';
         });
     }
     return $this->source;
 }