I am experiencing an issue when try to upload file of 4MB to S3 bucket using PHP SDK. 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. But small size of files can be uploaded without problem. Can someone please help me on this?
I am using nginx for both environments.
$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 "; 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. Idle connections will be closed. - RequestTimeoutYour socket connection to the server was not read from or written to within the timeout period.
Check that nginx has a parameter set like client_max_body_size 20M;
to allow file upload up to 20 MB. As for PHP, you could check in php.ini upload_max_filesize = 20M
to match nginx configuration.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.