Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Luciano_Canziani's avatar

Cannot upload to R2 via Laravel & S3 API?

Using Laravel 8 with Inertia and React.Js

I am bassicly getting this error:

Error executing "PutObject" on "https://hiddenforprivacy.cloudflarestorage.com/hiddenforprivacy/uploads/hiddenforprivacy.png"; AWS HTTP error: cURL error 35: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://hiddenforprivacy.hiddenforprivacy.r2.cloudflarestorage.com/hiddenforprivacy/uploads/hiddenforprivacy.png filesystems.php:

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL') . '/storage',
        'visibility' => 'public',
    ],
    'r2' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        /*  'region' => "", */
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
        'endpoint' => env('AWS_ENDPOINT'),
    ],
    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
        'endpoint' => env('AWS_ENDPOINT'),
        'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
    ],
],

Controller function:

public function createFotoInit(Request $request)
{

    $disk = 'r2';
    $validatedData = $request->validate([
        'profile_image' => 'nullable|image|mimes:jpeg,png,jpg,heic|max:6048',
    ]);

    if ($request->hasFile('profile_image')) {
        $path = Storage::disk($disk)->put('uploads', $request->file('profile_image'));
        if ($path) {
            return "Path: " . $path;
        } else {
            return "Failed to upload file.";
        }
    } else {
        return "No file was uploaded.";
    }
}
0 likes
1 reply
Luciano_Canziani's avatar

I manage to make it work by add http=>verify=>false in the filesystem.php file:

'r2' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => 'us-east-1', 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), 'endpoint' => env('AWS_ENDPOINT'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 'visibility' => 'public', 'throw' => false, 'http' => [ // ADD THIS 'verify' => false, ], ],

I guess I will have to comment it for production.

Please or to participate in this conversation.