Files
exchange-2.0/app/Classes/General/AWSS3Helper.php
T

32 lines
736 B
PHP

<?php
namespace App\Classes\General;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Carbon\Carbon;
class AWSS3Helper
{
/**
* @param string $methodName
* @return string
*/
static function S3($exportFileName, $exportableObject){
//Step 1: Upload to S3
$filePathForS3 = 'temp/' . $exportFileName;
$exportableObject->store($filePathForS3, 's3');
//Step 2: Return temporary URL from S3
$temporaryUrl = Storage::disk('s3')->temporaryUrl(
$filePathForS3,
Carbon::now()->addMinutes(10)
);
return $temporaryUrl;
}
}