Skip to content

Commit

Permalink
raise proper error when s3 object doesn't exist
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Nov 20, 2023
1 parent 37c4da8 commit ee8942c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/private/Files/ObjectStore/S3ObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Aws\S3\S3Client;
use Icewind\Streams\CallbackWrapper;
use OC\Files\Stream\SeekableHttpStream;
use OCP\Files\NotFoundException;

trait S3ObjectTrait {
/**
Expand Down Expand Up @@ -71,7 +72,11 @@ public function readObject($urn) {
];

$context = stream_context_create($opts);
return fopen($request->getUri(), 'r', false, $context);
$fh = fopen($request->getUri(), 'r', false, $context);
if (!$fh && isset($http_response_header[0]) && str_contains($http_response_header[0], '404')) {
throw new NotFoundException("object $urn not found in object store bucket " . $this->getBucket());
}
return $fh;
});
}

Expand Down

0 comments on commit ee8942c

Please sign in to comment.