Error sending files to aws S3 server in Laravel

Asked

Viewed 292 times

2

I am trying to send a file to the S3 server of Amazon, followed the documentation of Laravel 5.4 that talks about Filesystems. But it returns the error:

Error executing "ListObjects" on "https://s3.amazonaws.com/comercio-urbano?prefix=myfile.txt%2F&max-keys=1&encoding-type=url"; AWS HTTP error: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Routes

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index');
Route::get('/test', 'TesteController@teste');

Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class TesteController extends Controller
{
    public function teste()
    {
      echo '123';
      $s3 = Storage::disk('s3');
      $s3->put('myfile.txt', 'Teste', 'public');
    }
}

Filesystems

's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

.ENV

AWS_KEY=AKIAJKD62YA24W4T5QUA
AWS_SECRET=tbGRprt8vVXp5leUp5S65xVak0nZrLBZPPdO+fbC
AWS_REGION=us-east-1
AWS_BUCKET=comercio-urbano

Any suggestions?

  • These are not your real keys right (AWS_KEY, AWS_SECRET)? If they are, I suggest removing as some malicious user may use them.

  • It’s not the real one, I changed a few letters and numbers.

  • From what I saw of the indicated error: unable to get local issuer certificate problems in the certificate, are you using ssl location to send the file? Here are the error codes shown in the Curl link: https://curl.haxx.se/libcurl/c/libcurl-errors.html

  • 1

    @Evert Yes, that was the mistake right there, I took the codes from localhost and it worked. Thank you!

  • Since you decided to post as an answer to help others.

  • But you used on the server with ssl?

  • Uhum, I didn’t even have to change anything in the code. @Evert

Show 2 more comments

1 answer

1


When using flysystem, avoid using the domain localhost, create a hostname for the local machine, as below and should work:

http://local.dev

Browser other questions tagged

You are not signed in. Login or sign up in order to post.