J
J
jazzus2019-07-15 17:41:14
Amazon Web Services
jazzus, 2019-07-15 17:41:14

How to read pdf from S3 using Laravel?

So

$patch=Storage::disk('s3')->temporaryUrl($patch, now()->addMinutes(15));
return response()->file($patch);

writes that the file does not exist. When I directly follow the tempo link, it opens the file. Is it possible to show directly from s3 or only download to the server?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jazzus, 2019-07-15
@jazzus

$content = Storage::disk('s3')->get($path);

$header = [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="'.$file->name.'"'
];

return Response::make($content, 200, $header);

I
Ivan Shumov, 2019-07-15
@inoise

There are several options:
- make a public bucket or the object itself
- create a one-time iam policy and / or sts token (I don’t remember exactly)
- make a signed url in cloudfront

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question