[英]Upload Large size file to Amazon S3 fails on server
I am experiencing an issue when try to upload file of 4MB to S3 bucket using PHP SDK. 尝试使用PHP SDK将4MB的文件上传到S3存储桶时遇到问题。 This is working fine in my vagrant environment.
在我无所事事的环境中,这工作正常。 But when I try on EC2 production server, it gives below error when I am going to upload even 2MB size of file.
但是,当我尝试使用EC2生产服务器时,即使我要上传2MB大小的文件,它也会出现以下错误。 But small size of files can be uploaded without problem.
但是可以上传小文件而没有问题。 Can someone please help me on this?
有人可以帮我吗?
I am using nginx for both environments. 我在两种环境下都使用nginx。
$s3 = \App::make('aws')->createClient('s3');
$name= time() . $file->getClientOriginalName();
$resp = $s3->putObject(array(
'Bucket' => 'xxxxxx',
'Key' => $folder.'/' . $name,
'ACL' => 'public-read',
'Body' => new Stream(fopen(realpath($file->getPathName()), 'r'))
));
if ($resp['@metadata']['statusCode'] == 200) {
return [
"file_path"=>$resp['ObjectURL'],
"s3_key"=>$folder.'/' . $name
];
}else{
return false;
}
Error executing "PutObject" on " https://xxxxxxx.amazonaws.com/documents/1564900266slides.zip ";
在“ https://xxxxxxx.amazonaws.com/documents/1564900266slides.zip ”上执行“ PutObject”时出错; AWS HTTP error: Client error:
PUT https://xxxxxxx.amazonaws.com/documents/1564900266slides.zip
resulted in a400 Bad Request
response: RequestTimeoutYour socket connection to the server wa (truncated...) RequestTimeout (client): Your socket connection to the server was not read from or written to within the timeout period.AWS HTTP错误:客户端错误:
PUT https://xxxxxxx.amazonaws.com/documents/1564900266slides.zip
导致400 Bad Request
响应:RequestTimeout您到服务器的套接字连接wa(被截断了...)RequestTimeout(客户端):您的在超时时间内未读取或写入与服务器的套接字连接。 Idle connections will be closed.空闲连接将关闭。 - RequestTimeoutYour socket connection to the server was not read from or written to within the timeout period.
-RequestTimeout在超时时间内未读取或写入到服务器的套接字连接。
Check that nginx has a parameter set like client_max_body_size 20M;
检查nginx是否设置了诸如
client_max_body_size 20M;
类的参数client_max_body_size 20M;
to allow file upload up to 20 MB. 允许文件上传最大20 MB。 As for PHP, you could check in php.ini
upload_max_filesize = 20M
to match nginx configuration. 至于PHP,您可以签入php.ini
upload_max_filesize = 20M
以匹配nginx配置。
Once you have set those parameter you'd have to check nginx configuration with sudo nginx -t and reload configuration with sudo service nginx reload to apply the new settings. 设置完这些参数后,您必须使用sudo nginx -t检查nginx配置,并使用sudo服务nginx reload重新加载配置以应用新设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.