Amazon S3存储桶文件下载已损坏

时间:2020-09-22 07:43:53

标签: amazon-web-services amazon-s3 laravel-7

我正在尝试从s3存储桶下载文件,但是下载文件时,它没有打开损坏的文件。

我已经在这里检查了所有解决方案,但仍未解决我的问题。

这是我的功能。

public function get(string $path): string
{
    if ($this->storage->exists($path)) {
        return $this->storage->get($path);
    } else {
        try {
            $realPath = substr($path, strpos($path, '.com/') + 5);
            return $this->storage->disk('s3')->get($realPath);
        } catch (Exception $e) {
            return response()->json(
                'File not Found',
                Response::HTTP_NOT_FOUND
            );
        }
    }
}

0 个答案:

没有答案