Get file's signed URL from amazon s3 using Filesystem Laravel 5.2

Rômulo M. Farias :

I'm looking for a good solution to get the signed url from amazon s3.

I have a version working with it, but not using laravel:

private function getUrl ()
{
        $distribution = $_SERVER["AWS_CDN_URL"];

        $cf = Amazon::getCFClient();

        $url = $cf->getSignedUrl(array(
            'url'     => $distribution . self::AWS_PATH.rawurlencode($this->fileName),
            'expires' => time() + (session_cache_expire() * 60)));

        return $url;
}

I don't know if this is the best way to do with laravel, considering it has a entire file system to work...

But if don't have another way, how do I get the client? Debugging I've found an instance of it inside the Filesystem object, but it is protected...

brian_d :

In Laravel,

$s3 = \Storage::disk('s3');
$client = $s3->getDriver()->getAdapter()->getClient();
$expiry = "+10 minutes";

$command = $client->getCommand('GetObject', [
    'Bucket' => \Config::get('filesystems.disks.s3.bucket'),
    'Key'    => "file/in/s3/bucket"
]);

$request = $client->createPresignedRequest($command, $expiry);

return (string) $request->getUri();

Make sure you have the AWS for flysystem composer package too (version will vary):

"league/flysystem-aws-s3-v3": "1.0.9"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Upload file to amazon s3 server using laravel 5

From Dev

How to upload file to Amazon S3 pre-signed URL in Laravel?

From Dev

Laravel's Filesystem with s3 using the wrong url

From Dev

Read the contents of a file from AWS s3 using its Pre-signed URL

From Dev

Upload a file to AWS S3 pre-signed URL using Retrofit2

From Dev

Reading zip files from Amazon S3 using pre-signed url without knowing object key and bucket name

From Dev

How to upload a file to Amazon S3 and get the url in response using iOS

From Dev

How could I get file size, time and md5 from amazon s3?

From Java

Amazon S3 upload file and get URL

From Dev

How to get .stl file from Amazon S3 by using boto3?

From Dev

How to upload image file to Stripe from Amazon S3 using Laravel 5.5 and Intervention Image

From Dev

Playing m3u8 from Amazon S3 + CloudFront with Signed URL in Android

From Dev

Get the size of a folder in Amazon s3 using laravel

From Dev

How do I upload a file into an Amazon S3 signed url with python?

From Dev

Get image from URL and upload to Amazon S3

From Dev

Best practice to get pre-signed Amazon S3 download URL

From Dev

Uploading to Amazon S3 using a signed URL works with curl but not in javascript

From Dev

How to get file size from Amazon AWS S3 Version 2?

From Dev

get audio file object from amazon s3

From Dev

Download file from Amazon S3 using REST API

From Dev

Laravel Storage Filesystem and Amazon S3 gives CredentialsException

From Dev

Creating amazon aws s3 pre signed url PHP

From Dev

Amazon S3 Signed URL and Cloudfront - Access Denied

From Dev

ETag usage with Amazon S3 Pre-signed URL

From Dev

Upload file amazon s3 pre signed post

From Dev

Laravel s3 filesystem driver not using AWS_URL variable

From Dev

Hosting uploads on amazon s3 in a private bucket, accessing url's from within Laravel

From Dev

how to upload file to S3 bucket using pre-signed url in angular or javascript

From Dev

Error while creating signed url for getting file from s3 bucket?

Related Related

  1. 1

    Upload file to amazon s3 server using laravel 5

  2. 2

    How to upload file to Amazon S3 pre-signed URL in Laravel?

  3. 3

    Laravel's Filesystem with s3 using the wrong url

  4. 4

    Read the contents of a file from AWS s3 using its Pre-signed URL

  5. 5

    Upload a file to AWS S3 pre-signed URL using Retrofit2

  6. 6

    Reading zip files from Amazon S3 using pre-signed url without knowing object key and bucket name

  7. 7

    How to upload a file to Amazon S3 and get the url in response using iOS

  8. 8

    How could I get file size, time and md5 from amazon s3?

  9. 9

    Amazon S3 upload file and get URL

  10. 10

    How to get .stl file from Amazon S3 by using boto3?

  11. 11

    How to upload image file to Stripe from Amazon S3 using Laravel 5.5 and Intervention Image

  12. 12

    Playing m3u8 from Amazon S3 + CloudFront with Signed URL in Android

  13. 13

    Get the size of a folder in Amazon s3 using laravel

  14. 14

    How do I upload a file into an Amazon S3 signed url with python?

  15. 15

    Get image from URL and upload to Amazon S3

  16. 16

    Best practice to get pre-signed Amazon S3 download URL

  17. 17

    Uploading to Amazon S3 using a signed URL works with curl but not in javascript

  18. 18

    How to get file size from Amazon AWS S3 Version 2?

  19. 19

    get audio file object from amazon s3

  20. 20

    Download file from Amazon S3 using REST API

  21. 21

    Laravel Storage Filesystem and Amazon S3 gives CredentialsException

  22. 22

    Creating amazon aws s3 pre signed url PHP

  23. 23

    Amazon S3 Signed URL and Cloudfront - Access Denied

  24. 24

    ETag usage with Amazon S3 Pre-signed URL

  25. 25

    Upload file amazon s3 pre signed post

  26. 26

    Laravel s3 filesystem driver not using AWS_URL variable

  27. 27

    Hosting uploads on amazon s3 in a private bucket, accessing url's from within Laravel

  28. 28

    how to upload file to S3 bucket using pre-signed url in angular or javascript

  29. 29

    Error while creating signed url for getting file from s3 bucket?

HotTag

Archive