From dad18baec8274995ff384789ccc2577aabc6dde8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 20 Apr 2017 17:08:22 +0200 Subject: update aws sdk and move it to 3rdparty Signed-off-by: Robin Appelman --- apps/files_external/lib/Lib/Storage/AmazonS3.php | 38 +++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'apps/files_external/lib/Lib') diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 9dab25f7197..edcc084ae44 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -36,10 +36,6 @@ namespace OCA\Files_External\Lib\Storage; -set_include_path(get_include_path() . PATH_SEPARATOR . - \OC_App::getAppPath('files_external') . '/3rdparty/aws-sdk-php'); -require_once 'aws-autoloader.php'; - use Aws\S3\S3Client; use Aws\S3\Exception\S3Exception; use Icewind\Streams\CallbackWrapper; @@ -230,21 +226,29 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $files = array(); - $result = $this->getConnection()->getIterator('ListObjects', array( + $results = $this->getConnection()->getPaginator('ListObjects', [ 'Bucket' => $this->bucket, 'Delimiter' => '/', - 'Prefix' => $path - ), array('return_prefixes' => true)); - - foreach ($result as $object) { - if (isset($object['Key']) && $object['Key'] === $path) { - // it's the directory itself, skip - continue; + 'Prefix' => $path, + ]); + + foreach ($results as $result) { + // sub folders + if (is_array($result['CommonPrefixes'])) { + foreach ($result['CommonPrefixes'] as $prefix) { + $files[] = substr(trim($prefix['Prefix'], '/'), strlen($path)); + } + } + foreach ($result['Contents'] as $object) { + if (isset($object['Key']) && $object['Key'] === $path) { + // it's the directory itself, skip + continue; + } + $file = basename( + isset($object['Key']) ? $object['Key'] : $object['Prefix'] + ); + $files[] = $file; } - $file = basename( - isset($object['Key']) ? $object['Key'] : $object['Prefix'] - ); - $files[] = $file; } return IteratorDirectory::wrap($files); @@ -270,7 +274,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { )); $stat['size'] = $result['ContentLength'] ? $result['ContentLength'] : 0; - if ($result['Metadata']['lastmodified']) { + if (isset($result['Metadata']['lastmodified'])) { $stat['mtime'] = strtotime($result['Metadata']['lastmodified']); } else { $stat['mtime'] = strtotime($result['LastModified']); -- cgit v1.2.3