Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/files_external/lib/Lib/Storage/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OCP\Constants;
use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\NotPermittedException;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\ITempManager;
Expand Down Expand Up @@ -772,7 +773,15 @@ public function writeStream(string $path, $stream, ?int $size = null): int {
}

$path = $this->normalizePath($path);
$this->writeObject($path, $stream, $this->mimeDetector->detectPath($path));
try {
$this->writeObject($path, $stream, $this->mimeDetector->detectPath($path));
} catch (S3Exception $exception) {
$this->logger->error($exception->getMessage(), [
'app' => 'files_external',
'exception' => $exception,
]);
throw new NotPermittedException($exception->getMessage(), $exception->getCode(), $exception);
}
$this->invalidateCache($path);

return $size;
Expand Down
4 changes: 4 additions & 0 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\Files\IFilenameValidator;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\InvalidPathException;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage\IConstructableStorage;
use OCP\Files\Storage\ILockingStorage;
use OCP\Files\Storage\IStorage;
Expand Down Expand Up @@ -562,6 +563,9 @@ public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalP
try {
$this->writeStream($targetInternalPath, $source);
$result = true;
} catch (NotPermittedException $e) {
Server::get(LoggerInterface::class)->warning('Failed to copy stream to storage', ['exception' => $e]);
Comment thread
mejo- marked this conversation as resolved.
throw new ForbiddenException($e->getMessage(), false, $e);
} catch (\Exception $e) {
Server::get(LoggerInterface::class)->warning('Failed to copy stream to storage', ['exception' => $e]);
}
Expand Down
Loading