David L
David L

Reputation: 626

Laravel Storage Filesystem and Amazon S3 gives CredentialsException

I'm trying to use Filesystem, the implementation of league/flysystem-aws-s3-v3 with Laravel 5.1. but I can get the files from S3.

So, I coded this:

$s3 = Storage::disk('s3');
$imageName = Employee::filePath() . $employee->id . '.pdf';

if (Storage::disk('s3')->exists($imageName)) {
    return response()->download(Storage::disk('s3')->get($imageName));
}

Then I get the follow error:

CredentialsException in InstanceProfileProvider.php line 79: Error retrieving credentials from the instance profile metadata server. (cURL error 28: Connection timed out after 1001 milliseconds (see http://curl.haxx.se/libcurl/c/libcurl-errors.html))

The credential are set on config/filesystems.php, I know are good because I can put files there.

Do you have any idea?

Thanks in advance.

Upvotes: 2

Views: 1993

Answers (1)

David L
David L

Reputation: 626

The problem was with my configuration, I was trying to setup with env, however for some reason doesn't load at moment of configuration, so I decide put directly on the configuration file filesystems.php

's3' => [
            'driver' => 's3',
            'key'    => 'XXXXXXXXXX',
            'secret' => 'XXXXXXXXXX',
            'region' => env('S3_REGION'),
            'bucket' => env('S3_BUCKET'),
        ],

Upvotes: 3

Related Questions