du970294 2019-05-29 22:42
浏览 97

使用php处理驻留在AWS S3存储桶中的jpg图像属性

I've been tasked with resizing and possibly rotating images stored in an S3 bucket based on a set of business rules.

The following function is able to retrieve and echo the object keys:

public function retrieveObjects($orderNumber)
{
    try {
        $objects = $this->s3Client->listObjects([
            'Bucket' => 'designproofs',
            'Prefix' => $this->path . $orderNumber . '/'
        ]);
        if(is_array($objects['Contents'])) {
            foreach ($objects['Contents'] as $object) {
                $result = $this->s3Client->getObject([
                    'Bucket' => 'designproofs',
                    'Key'   => $object['Key'],
                ]);
                echo $object['Key'] . "<br>";

            }
        }
        else{
            echo $objects['Key'] . "<br>";
            echo $result['Body'] . "<br>";
        }
    } catch (S3Exception $e) {
        echo $e->getMessage() . PHP_EOL;
    }
}

The $result['Body'] appears to be the binary image data -though I am not entirely certain.

Can I store these images in a variable and manipulate them without the need to write the file to a physical medium (HDD etc.)?

* EDIT *

The images can be easily stored with the following:

$result = $this->s3Client->getObject([
    'Bucket' => 'easyflow-designproofs',
    'Key' => $object['Key'],
    'SaveAs' => 'upload/temp_images/' . $fileName
]);
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度