PHP and AWS | Copy AWS S3 file to local folder

|
| By Webner

How to copy a file from Amazon s3 to some local folder using PHP code

$t=file_put_contents(‘[Destination file address]’, file_get_contents(“[S3 url]”));

Here $t will get the size of file in bytes if successful otherwise 0. Before executing this make sure that the S3 file has access permission and the destination file also has write permission.

S3 url is like https://s3.ap-south-1.amazonaws.com/[bucket]/[filename]

Leave a Reply

Your email address will not be published. Required fields are marked *