pandesantos
pandesantos

Reputation: 369

Minio with laravel, bucket name prefixed as a subdomain on a local server

I'am using minio for file storage, also i've configured it all using docker-compose. My laravel filesystem configuration file looks like this.

's3' => [
        'driver' => 's3',
        'key' => '',
        'secret' => '',
        'region' => 'ap-southeast-1',
        'bucket' => 'students',
        'endpoint' => 'http://minio:9000',
    ]

I can access minio web dashboard using http://minio:9000. But while storing an object I'm encountering following errors.

// code to store file
Storage::disk('s3')->put($bucketFolder . $name, file_get_contents($file));

//Exception thrown
Error executing "PutObject" on "http://students.minio:9000/misc/1641374889-1033010763.png"; AWS HTTP error: cURL error 6: Could not resolve host: students.minio (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://students.minio:9000/misc/1641374889-1033010763.png

I don't why students. is being added to the endpoint url.

Upvotes: 5

Views: 4195

Answers (3)

andreasm
andreasm

Reputation: 136

This did not work for me:

'bucket_endpoint' => true

Instead this worked:

'use_path_style_endpoint' => true,

I got it from here: Maximum execution time with Laravel and LocalStack

Upvotes: 0

primus
primus

Reputation: 50

Arrived at similar problem in golang where there is config property S3ForcePathStyle

s3Config := &aws.Config{
    Credentials: credentials.NewStaticCredentials(apiKey, apiSecret, ""),
    Endpoint:         "http://minio:9000",
    Region:           "ap-southeast-1",
    S3ForcePathStyle: aws.Bool(true), // bool pointer
}

Upvotes: 0

pandesantos
pandesantos

Reputation: 369

I got it right by modifying config.php like below. If anyone has other options please suggest.

's3' => [
        'driver' => 's3',
        'key' => '',
        'secret' => '',
        'region' => 'ap-southeast-1',
        'bucket' => 'students',
        'bucket_endpoint' => true, // added
        'endpoint' => 'http://minio:9000/students',
    ]

Upvotes: 4

Related Questions