Function RtnAWSUpload($wrkProdFileLocation,$wrkAWSFileLocation)
{
$bucket = 'somebucket';
$keyname = 'somekey';
$secretkey = 'someprvkey'; // PRVKEY
// echo '<BR><BR>AT AWS UPLOAD RTN';
$s3 = new S3Client([
'version' => 'latest',
'region' => 'us-east-2',
'credentials' => array('key'=>$keyname,
'secret'=>$secretkey)
]);
try {
// UPLOAD FILE TO AWS BUCKET
$result = $s3->putObject([
'Bucket' => $bucket,
'Key' => $wrkAWSFileLocation,
'SourceFile' => $wrkProdFileLocation,
'ACL' => 'public-read'
]);
// PRINT URL TO OBJECT
//echo '<BR><BR>AWS FILE UPLOAD RESULT: ' . $result['ObjectURL'] . PHP_EOL;
$strAWSUploadResult = $result['ObjectURL']; // need to return the numeric status code instead of message)
$_SESSION['NbrOfFilesUploaded'] = ($_SESSION['NbrOfFilesUploaded'] + 1);
} catch (S3Exception $e) {
echo $e->getAwsErrorCode() . PHP_EOL;
echo $e->getMessage() . PHP_EOL;
}
return $strAWSUploadResult;
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.