diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 0e9c4ebc12012..8ab718a50980b 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -163,7 +163,13 @@ private function doesDirectoryExist($path) { 'MaxKeys' => 1, 'Delimiter' => '/', ]); - $this->directoryCache[$path] = ($result['Contents'][0]['Key'] === rtrim($path, '/') . '/') || $result['CommonPrefixes']; + + if ((isset($result['Contents'][0]['Key']) && $result['Contents'][0]['Key'] === rtrim($path, '/') . '/') + || isset($result['CommonPrefixes'])) { + $this->directoryCache[$path] = true; + } else { + $this->directoryCache[$path] = false; + } } catch (S3Exception $e) { if ($e->getStatusCode() === 403) { $this->directoryCache[$path] = false;