shopwwi / webman-filesystem

Flysystem V2/V3 adapter for the webman
22 stars 3 forks source link

使用s3适配器的可见性问题 #8

Closed ygcool closed 8 months ago

ygcool commented 9 months ago

除了在config/plugin/shopwwi/filesystem/app.php中,s3配置中加一个'ACL' => 'public-read', 来保障上传的图片可公共读,有办法能在上传的时候指定吗? 有些时候上传的文件需要配置其他的ACL规则

我的上传使用这种方式:

try {
    $file = $request->file('__file__');
    $fileName = '1.png'; // 文件名中如此带了路径 则下面的path无效 未带路径1.png效果相等
    $ext = true; // 文件尾缀是否替换 开启后则$files上传的任意图片 都会转换为$fileName尾缀(示例: .png),默认false
    $result = Storage::adapter('s3')
        ->path('path/logo')
        ->size(1024*1024*5)
        ->reUpload($file, $fileName, $ext);

    var_dump($result);
}catch (\Exception $e){
    Log::error($e);
}
phcent commented 8 months ago

Storage::setConfig([])->adapter('s3')