使用SimpleImage调整图像大小并将其直接发送到Amazon S3

After upload images i resize them using SimpleImage and send to AWS S3. Today i am saving the images in local disk, sending to S3 and then delete the local files. I would like skip to step do save and delete the local files.

I tried:

$S3->putObject([
    'Bucket' => 'mybucket',
    'Key'    => 'myfile.jpeg',
    'Body'   => (new SimpleImage('/path/to/myfile.jpeg'))
                    ->bestFit(
                        800,
                        600
                    )->toString();
]);

The file is sended, but when i access its public URL at AWS S3, the browser tries to download the file and don't show it.

Any help will be welcome!

You need to make the object public and add ContentType

$S3->putObject([
    'Bucket'      => 'mybucket',
    'Key'         => 'myfile.jpeg',
    'ContentType' => 'image/jpeg',     // <-- add this line
    'Body'        => (new SimpleImage('/path/to/myfile.jpeg'))
                        ->bestFit(
                            800,
                            600
                      )->toString();
]);