DIPAK KUMAR SINGH
DIPAK KUMAR SINGH

Reputation: 113

Amazon AWS s3 upload using image content - PHP

I am using the following code to upload image to the ECS server. Here I am first storing the image first to a temporary location and then uploading that to the server.

$result = $s3->putObject(array(
                   'Bucket' => $this->bucket,
                'SourceFile' => $temp,
                    'Key'    => $Destination_folder,
                    'ACL'    => 'public-read',
                    'ContentType' => 'text/plain',
                    'Expires' => $expire
                     ));

I want to remove the use of this temporary location. So is there any way to upload image directly using the image content only.

Upvotes: 3

Views: 962

Answers (1)

Ishan Tiwary
Ishan Tiwary

Reputation: 1008

Try using 'Body' of s3 putObject for image content.

 $result = $s3->putObject(array(
            'Bucket' => $this->bucket,
            'Key'    => $Destination_folder,
            'Body'   => $image_content 
            ));

Upvotes: 9

Related Questions