Amazon AWSSDKforPHP too slow
Hi,
I am using Amazon AWSSDKforPHP to connect my web application to S3. But there is a problem with the process or service requests that make it too slow.
For example, I have this code:
foreach($images as $image){
$urls[] = $s3->get_object_url($bucket, 'users/'.trim($image).'.jpg', '5 minutes');
}
Assuming $ images is an array of user images, this returns an array called $ urls, which has (in his words) the URL of these images with credentials for 5 minutes. This request takes at least 6 seconds with 35 images, and this is normal. But ... when the images do not exist in the bucket, I want to set the default image for the user, something like "images / noimage.png". Here is the code:
foreach($images as $image){
if($s3->if_object_exists($bucket, 'users/'.trim($image).'.jpg')){
$urls[] = $s3->get_object_url($bucket, 'users/'.trim($image).'.jpg', '5 minutes');
} else {
$urls[] = 'http://www.example.com/images/noimage.png';
}
}
, SLOOOOOW. "$ s3- > if_object_exists()" Script 40 35 !
Script, cURL:
foreach($images as $image){
$ch = curl_init($s3->get_object_url($bucket, 'users/'.trim($image).'.jpg', '1 minutes') );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$res = curl_getinfo($ch,CURLINFO_HTTP_CODE);
if($res == 200){
$urls[] = $s3->get_object_url($bucket, 'users/'.trim($image).'.jpg', '5 minutes');
}else{
$urls[] = 'http://www.example.com/images/noimage.png';
}
}
Script 16 18 . , : (.
, .
.