flownative / flow-aws-s3

Amazon S3 adaptor for Neos and Flow
MIT License
18 stars 33 forks source link

Custom Endpoint gets prefixed with bucket-name - add "use_path_style_endpoint" to config #42

Closed paavo closed 3 years ago

paavo commented 3 years ago

A custom Endpoint-URI should not be prefixed with the bucket-name. I configured a custom Endpoint (https://cz42.objectstorage.provider.tld/my-bucket-name) When uploading a File the Endpoint-URI gets prefixed with the bucket-name: https://my-bucket-name.cz42.objectstorage.provider.tld/1Flownative.Aws.S3.ConnectionTest.txtmy-bucket-name. should not be in the Endpoint-URI


Steps to reproduce:

  1. Add a custom Endpoint: https://cz42.objectstorage.provider.tld/my-bucket-name
Flownative:
  Aws:
    S3:
      profiles:
        default:
          endpoint: 'https://cz42.objectstorage.provider.tld/my-bucket-name'
  1. Upload a Test-File php ./flow s3:connect --bucket my-bucket-name

  2. I get an Error the Endpoint-URI can't be found: Error executing “PutObject” on “https://my-bucket-name.cz42.objectstorage.provider.tld/1Flownative.Aws.S3.ConnectionTest.txt”

kdambekalns commented 3 years ago

Where does that 1 come from in the URL? Is that expected? Or could that be a string representation of an unexpected boolean?

kdambekalns commented 3 years ago

Quickly checked the code, and we don't add the bucket name to the endpoint. Maybe the SDK does something magic here (that it didn't do in the past) or it uses some environment variables that are floating around?!

paavo commented 3 years ago

Quickly checked the code, and we don't add the bucket name to the endpoint. Maybe the SDK does something magic here (that it didn't do in the past) or it uses some environment variables that are floating around?!

Weird.. NO, there's no environment variable set (except FLOW_CONTEXT) Maybe i can try downgrading the aws/aws-sdk-php

paavo commented 3 years ago

Where does that 1 come from in the URL? Is that expected? Or could that be a string representation of an unexpected boolean?

Looks like this is the prefix which is not set 🤔 https://github.com/flownative/flow-aws-s3/blob/4d77ab1f7813778c2011e5acf03f6e713dcbfb92/Classes/Command/S3CommandController.php#L55

After adding keyPrefix: '/'the Path is correct: /Flownative.Aws.S3.ConnectionTest.txt

paavo commented 3 years ago

@kdambekalns Fixed 🎉 The solution was to add the use_path_style_endpoint to the config.

Flownative:
  Aws:
    S3:
      profiles:
        default:
          use_path_style_endpoint: true