Laravel: 存储器::url()返回错误的bucket.

问题描述 投票:0回答:1

我正在上传一个文件到S3并指定一个桶。 当我检查我的S3仪表板时,它在正确的地方和正确的桶(s3-legacy-users). 但是,当我去检索URL时,这个bucket不是 s3-legacy-users 但却用了不同的桶。 有没有一种方法可以在使用 Storage::url() ?

    $file = $request->file('file');

    $fileName = $file->hashName();
    $image = Image::make($file->getRealPath());

    $newPath = '/'.shop_id().'/'.$imageType.'-'.$fileName;

    $fileUpload = Storage::disk('s3-legacy-users')->put($newPath, $image->stream()->__toString());
    $filePath = Storage::url($newPath);

    dd($filePath);
laravel laravel-5
1个回答
1
投票

如果你有几个存储驱动,你需要指定你的磁盘。

$filePath = Storage::disk('s3-legacy-users')->url($newPath);

1
投票

你试过吗?

php artisan storage:link
© www.soinside.com 2019 - 2024. All rights reserved.