php convert images and upload to amazon s3
Posted
by
faraklit
on Stack Overflow
See other posts from Stack Overflow
or by faraklit
Published on 2010-12-31T16:47:45Z
Indexed on
2010/12/31
16:54 UTC
Read the original article
Hit count: 184
I am looking for a best practice while uploading images to amazon s3 server and serving from there.
We need four different sizes of an image. So just after image upload we convert the image and scale in 4 different widths and heights. And then we send them to the amazon s3 using official php api.
// ...
// image conversions, bucket setting, s3 initialization etc.
$sizes= array("", "48", "64", "128");
foreach($sizes as $size) {
$filename = $upload_path.$dest_file.$size.$ext;
$s3->batch()->create_object($bucket, , array(
'fileUpload' => $filename,
'acl' => AmazonS3::ACL_PUBLIC,
));
}
But for a 1M image the client sometimes wait up to 30 seconds which is a very long time.
Instead of sending images immediately to S3, it may be better to add them to a job queue. But the user should see the uploaded image immediately.
© Stack Overflow or respective owner