我正在上传文件到S3:
在文件系统中我有:
'default' => 's3',
'cloud' => 's3',
's3' => [
'driver' => 's3',
'key' => '***********',
'secret' => '********************',
'region' => '************',
'bucket' => '*************',
],
],
'parent_url' => 'http://54.169.67.54/',
];
一切正常,但上传文件时出现错误。
fopen(/var/www/html/project/public/photos/profile-pics/1-medium-1470892864.jpg): failed to open stream: Permission denied
使用League'Flysystem并检查此参数以获取进一步参考
示例:
public function uploadFile( $getFile )
{
try{
$datetimefilename = Carbon::now()->format('YmdHis');
$ext = $getFile->getClientOriginalExtension();
$filename = sprintf('%s.%s', $datetimefilename,$ext);
$uploadPath = env('UPLOAD');
if( Storage::disk('s3')->has($uploadPath) === false ){
Storage::disk('s3')->createDir($uploadPath);
}
$filePath = sprintf('%s/%s',$uploadPath,$filename);
$result = Storage::disk('s3')->put($filePath, file_get_contents($getFile->getRealPath()));
return $result ;
}
catch('Exception $e)
{
return false;
}
}