问题
Is it possible for me to use the writeImage function in Imagick to write an image directly to an S3 bucket? If so, how? I'm pretty new to the Amazon S3 SDK, so some help would be appreciated.
回答1:
With writeImage, probably not (it takes a file path as argument, thus writing the file to the filesystem), but you can getImageBlob
to get the image as binary string which you can then easily write to S3 with certain name. It would be easiest for you to use an S3 PHP library, there is one official in the AWS PHP SDK, or there are 3rd party libraries as well, such as this one:
https://github.com/mackstann/amazon-s3-php-class
// Put an object from a string:
$s3->putObject($string, $bucketName, $uploadName, S3::ACL_PUBLIC_READ)
来源:https://stackoverflow.com/questions/11286222/php-imagick-write-image-directly-to-amazon-s3