Hossein Jalali
Hossein Jalali

Reputation: 332

CodeIgniter and S3 putObject - getting the right path to file

I am having trouble passing the correct URL of an image from CI to S3 servers.

My image is stored in the root folder under assets/image.jpg

$this->load->library('s3');
$this->s3->putObject('../../image.jpg', $bucket, 'testimage.jpg', 'public-read');

The bucket creates the file testimage.jpg however it is just a 20kb file that is corrupt.

Can someone let me know how to get the right path to the image?

I have already tried:FCPATH . 'asset/image.jpg' and it did not work.

NOTE: I am doing this on my localhost, if that matters.

Upvotes: 0

Views: 1172

Answers (1)

Hossein Jalali
Hossein Jalali

Reputation: 332

I have found the answer to the question and hopefully it can help someone else some time:

$this->s3->putObject(S3::inputFile('asset/image.jpg'), $bucket, 'testimage.jpg', 'public-read');

It was required to put S3::inputFile('folder/file').

Upvotes: 1

Related Questions