Skip to content

Storage Adaptor for S3 only supports Amazon S3: Please add some options for the S3 Client #655

@osseonews

Description

@osseonews

The S3 adapter appears to assume only AWS S3. But there are may S3 compatible storage providers, like Cloudflare R2 and Digital Ocean Spaces (which we use) that will work with the @aws-sdk/client-s3, but just require the necessary options. The S3 Client set up in the plugin doesn't include the necessary lines for these compatible storage providers. For for example, when used with DigitalOcean Spaces, setupLifecycle() fails because the client does not support configuring a custom endpoint and performs AWS-specific bucket lifecycle operations. Could the adapter support an optional endpoint configuration?

The fix is really simple, in your code, you just need to add 2 new options for the S3 Client:

your Code:

this.s3 = new S3Client({ region: this.options.region, credentials: { accessKeyId: this.options.accessKeyId, secretAccessKey: this.options.secretAccessKey, }, })

Just add 2 options, (see below)

Add the other necessary options for Digital Ocean Spaces:

  1. endpoint and
  2. forcePathStyle.

An S3 client config for Digital Ocean looks like this basically

private constructor(config: S3Config) {
    

        this.config = {
            endpoint: config.endpoint, //you are mising this!
            accessKeyId: config.accessKeyId,
            secretAccessKey: config.secretAccessKey,
            bucket: config.bucket,
        };

        this.s3 = new S3Client({
            endpoint: this.config.endpoint,
            region: "us-east-1", // required even for S3-compatible services - can store in ENV
            credentials: {
                accessKeyId: this.config.accessKeyId,
                secretAccessKey: this.config.secretAccessKey,
            },
            forcePathStyle: true, // important for many S3-compatible providers
        });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions