mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-30 09:53:58 +00:00
32 lines
736 B
PHP
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;
|
|
}
|
|
|
|
}
|