diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 23f6592581..b455994359 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -160,10 +160,11 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $result = $this->getConnection()->listObjects([ 'Bucket' => $this->bucket, - 'Prefix' => rtrim($path, '/') . '/', + 'Prefix' => rtrim($path, '/'), 'MaxKeys' => 1, + 'Delimiter' => '/', ]); - $this->directoryCache[$path] = $result['Contents'] || $result['CommonPrefixes']; + $this->directoryCache[$path] = ($result['Contents'][0]['Key'] === rtrim($path, '/') . '/') || $result['CommonPrefixes']; } catch (S3Exception $e) { if ($e->getStatusCode() === 403) { $this->directoryCache[$path] = false;