PHP Imagick: Write Image directly to Amazon S3?

柔情痞子 提交于 2019-12-08 06:24:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!