i have application with below steps,
- User signup and purchase the course
- User submits the answer writing pdf file in application to AWS s3 storage. and i have a piece of code like below,
Upload to S3
$path = $request->file('answer_file')->store('pdffiles','s3');
return $path;
In AWS i have created a bucket with default configuration and i have created a IAM user. S3 bucket is private and i have not touched other confgurations.
And to view the particular file i have a code like below,
$file_path = "pdffiles/filename.pdf";
$client = Storage::disk('s3')->getDriver()->getAdapter()->getClient();
$bucket = config('filesystems.disks.s3.bucket');
$command = $client->getCommand('GetObject', [
'Bucket' => $bucket,
'Key' => $file_path // file name in s3 bucket which you want to access
]);
$request = $client->createPresignedRequest($command, '+5 minutes');
$presignedUrl = (string) $request->getUri(); // Get the actual presigned-url
$headers = [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="filename.pdf"',
];
return Response::make($presignedUrl, 200, $headers);
So i am able to download the pdf file and also expiry thing also working fine.
i am new to AWS s3 storage so i am wondering if this is good enough for a files where only authenticated users can access the files.
It would be helpfull if anyone guide me if any extra things i should consider.