logger = $logger ?? new NullLogger(); $client = new S3Client([ 'endpoint' => $endpoint, 'credentials' => [ 'key' => $key, 'secret' => $secret, ], 'region' => $region, 'version' => 'latest', 'use_path_style_endpoint' => true, ]); $this->filesystem = new Filesystem( new AwsS3V3Adapter($client, $bucket), ); } #[Override] public function upload(string $path, mixed $content, string $mimeType): string { $config = [ 'ContentType' => $mimeType, ]; if (is_resource($content)) { $this->filesystem->writeStream($path, $content, $config); } else { $this->filesystem->write($path, (string) $content, $config); } return $path; } #[Override] public function delete(string $path): void { try { $this->filesystem->delete($path); } catch (UnableToDeleteFile $e) { $this->logger->warning('S3 delete failed, possible orphan blob: {path}', [ 'path' => $path, 'error' => $e->getMessage(), ]); } } #[Override] public function readStream(string $path): mixed { try { return $this->filesystem->readStream($path); } catch (UnableToReadFile $e) { throw new RuntimeException(sprintf('Impossible de lire le fichier : %s', $path), 0, $e); } } }