php - CodeIgniter and S3 putObject - getting the right path to file

558

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.

587

Answer

Solution:

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 putS3::inputFile('folder/file').

People are also looking for solutions to the problem: php - Cannot insert values into database from HTML Forms

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.