isValidFileName($fileName)) { throw new \InvalidArgumentException("Invalid file name: $fileName"); } } /** * @inheritDoc */ public function requireValidFilePath(string $filePath): void { if (!$this->isValidFilePath($filePath)) { throw new \InvalidArgumentException("Invalid file path: $filePath"); } } public function isFileInStore(string $fileName): bool { // Check if the file exists in the store return self::doesObjectExist($fileName); } public function download(string $file): string { $path = '/tmp/' . $file; $result = self::getS3Client()->getObject([ 'Bucket' => self::getBucket(), 'Key' => $file, 'SaveAs' => $path ]); return $path; } public function generateDirectDownloadUrl(string $fileName): string { $host = 'https://api.truckwash.io'; $this->requireValidFilePath($fileName); $encodedPath = implode('/', array_map('rawurlencode', explode('/', $fileName))); // Generate a direct download URL for the given file name return $host . '/files/' . $encodedPath; } }