Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use the Amazon S3 Media module with a local storage emulator, implement support for it if necessary #15676

Closed
Piedone opened this issue Apr 7, 2024 · 1 comment · Fixed by #15677

Comments

@Piedone
Copy link
Member

Piedone commented Apr 7, 2024

Is your feature request related to a problem? Please describe.

Following the docs, you can only use the Amazon S3 Media module with a real, online S3 resource. For daily development, especially in a team, using a storage emulator is better though. This is currently an issue only for the Amazon Media Storage feature, but after #15028, it'll be for Amazon Media ImageSharp Image Cache too.

AFAIK, with the AWS SDK version we use currently, and due to us using virtual host addressing for buckets (i.e. mybucket.localhost, as opposed to path-style addressing with localhost/mybucket) this isn't actually possible, so we need to implement support for it too. I elaborate my attempts below.

  • S3rver can be made work as far as creating and accessing buckets with the below config, but file uploads fail with “Expected hash not equal to calculated hash”. This is related to us using the almost latest AWS SDK and a breaking change in it; unfortunately, due to S3rver being unmaintained, it's hopeless that it'll be fixed.

appsettings:

    "OrchardCore_Media_AmazonS3": {
      "ServiceURL": "http://localhost:4568/",
      "Profile": "default",
      "ProfilesLocation": "",
      "Credentials": {
        "SecretKey": "S3RVER",
        "AccessKey": "S3RVER"
      },
      "BasePath": "/{{ ShellSettings.Name }}",
      "CreateBucket": true,
      "RemoveBucket": true, // Whether the 'Bucket' is deleted if the tenant is removed, false by default.
      "BucketName": "ocmedia"
    },
    // See https://docs.orchardcore.net/en/latest/docs/reference/modules/Media.AmazonS3/#configuration to configure media storage in Amazon S3 Storage.
    "OrchardCore_Media_AmazonS3_ImageSharp_Cache": {
      "ServiceURL": "http://localhost:4568/",
      "Profile": "default",
      "ProfilesLocation": "",
      "Credentials": {
        "SecretKey": "S3RVER",
        "AccessKey": "S3RVER"
      },
      "BasePath": "/{{ ShellSettings.Name }}",
      "CreateBucket": true,
      "RemoveBucket": true, // Whether the 'Bucket' is deleted if the tenant is removed, false by default.
      "BucketName": "ocimagesharp"
    },

Windows hosts:

::1 ocmedia.localhost
::1 ocimagesharp.localhost
127.0.0.1 ocmedia.localhost
127.0.0.1 ocimagesharp.localhost

Describe the solution you'd like

Document how a storage emulator can be used. However, as detailed above, most possibly none of the existing emulators will work.

Describe alternatives you've considered

Alternatively, we’d need to use path-style buckets with ForcePathStyle, see aws/aws-sdk-net#2571, but that we can’t really set in the way we currently use the AWS SDK (at least I didn't find a way to do that without completely overhauling the code). See Configure S3 client ServiceURL with AWSCredentials or RegionEndPoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant