//--------------------------------
//----- DOWNLOAD THE S3 FILE -----
//--------------------------------
//Create temporary file destination
if (!is_dir($full_path_to_api . 'temp/')) {
mkdir($full_path_to_api . 'temp', 0777, true);
}
$LocalFilename = $full_path_to_api . 'temp/working_import.txt';
unlink($LocalFilename); //Delete file destination if it already exists
$DownloadSuccess = false;
try
{
//----- SETUP AWS SDK FOR S3 ACCESS -----
$sdk = new Aws\Sdk([
'version' => 'latest',
'region' => 'us-west-2',
'credentials' => [
'key' => AWS_S3_ACCESS_KEY_ID, //<<<<< S3 ACCESS KEY ID
'secret' => AWS_S3_ACCESS_SECRET_KEY, //<<<<< S3 SECRET ACCESS KEY
],
]);
$s3Client = $sdk->createS3();
$result = $s3Client->getObject([
'Bucket' => AWS_S3_BUCKET_NAME,
'Key' => $S3Filename,
'SaveAs' => $LocalFilename
]);
$DownloadSuccess = true;
}
catch (Exception $e)
{
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.