Skip to content

feat: Add compatibility improvements to S3CloudStorage for S3-compatible providers (MinIO, LocalStack, etc.) - #4200

Closed
mathis6787 wants to merge 22 commits into
serverpod:mainfrom
mathis6787:feature/add-s3-host-override
Closed

mathis6787 wants to merge 22 commits into
serverpod:mainfrom
mathis6787:feature/add-s3-host-override

Conversation

@mathis6787

Copy link
Copy Markdown
Contributor

This PR improves the compatibility of S3CloudStorage with S3-compatible providers such as MinIO, LocalStack, and other self-hosted or local S3 implementations.
It aligns the behavior of Serverpod with non-AWS S3 providers while preserving full AWS S3 compatibility.

These adjustments make the S3 storage backend usable in local development environments and with S3-compatible services.

⸻

💡 Why

Many developers use S3-compatible storage such as MinIO or LocalStack for:
• local development
• CI testing
• on-premise/self-hosted deployments

Serverpod’s current S3 implementation is AWS-specific, which makes it difficult to use these environments.
This PR expands compatibility without introducing breaking changes.

⸻

❌ Breaking changes

None — existing AWS configurations continue to work exactly the same.

@coderabbitai

coderabbitai Bot commented Nov 13, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Nov 13, 2025 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@mathis6787 mathis6787 changed the title Add compatibility improvements to S3CloudStorage for S3-compatible providers (MinIO, LocalStack, etc.) feat: Add compatibility improvements to S3CloudStorage for S3-compatible providers (MinIO, LocalStack, etc.) Nov 13, 2025
@mathis6787

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@nielsenko nielsenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some first feedback

@mathis6787
mathis6787 force-pushed the feature/add-s3-host-override branch from d9b52e7 to de70c70 Compare November 19, 2025 16:13

@nielsenko nielsenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have added a number of optional arguments at various places, that is needed when building endpoints in the case we are not calling aws s3.

Would it be an idea, to abstract the code that needs these arguments into a callback type, use a default version for S3, and allow caller to pass another factory if needed?

This way you get more flexibility and less custom params (only an optional callback)?

Just food for thought. Otherwise, I'm prepared to accept this PR.

@mathis6787

mathis6787 commented Nov 20, 2025 •

Copy link
Copy Markdown
Contributor Author

Hi! Thanks a lot for the feedback — I appreciate it.

I am new to open source contribution so before implementing the factory/callback abstraction, I want to confirm one important point to avoid going in the wrong direction because I am not sure to understand your intention.

✔️ My current understanding

The idea is to avoid having multiple optional parameters (endpointUrl, host, useHttps, etc.) and replace them with a single abstraction (factory or similar) that lets callers customize the S3 client in a cleaner, more flexible way.

✔️ Why I’m unsure about the factory-only approach

A clientFactory gives full control over how AwsS3Client is created.
But the issue is that AwsS3Uploader does not use AwsS3Client at all.

It builds its own URL internally:
• hard-coded AWS URL:
https://$bucket.s3-$region.amazonaws.com
• and in my PR I added:
endpointUrl so MinIO / LocalStack works

Because AwsS3Uploader is completely independent from AwsS3Client:

➤ Even if we add a clientFactory,

we would still need endpointUrl on AwsS3Uploader anyway.

So the factory alone does not remove optional parameters from the constructor.

This is why I’m unsure how the factory solves the “too many optional S3 params” problem.

✔️ Why an override object may be more consistent

If we had something like:

 class S3Overrides {
  final String? endpointUrl;
  final String? host;
  final bool useHttps;
}

Then both components could use it:
• AwsS3Client → host, useHttps
• AwsS3Uploader → endpointUrl,
• getPublicUrl → useHttps
• createDirectFileUploadDescription → endpointUrl

In that approach, the only optional parameter of S3CloudStorage would be a single overrides argument, and callers would pass a S3Overrides object.
This removes all the individual optional parameters (endpointUrl, host, useHttps, etc.) from the constructor and centralizes S3-compatibility settings in one place.

  1. Do you prefer that both AwsS3Client and AwsS3Uploader receive the same S3Overrides object?
    So overrides are applied consistently everywhere.
  2. Or do you want clientFactory callback and we let in the S3CloudStorage constructor the optional params endpointUrl (may be modify to endpointOverride to be more explicit) ?
    (Factory only handles the client, override object handles uploader)

@nielsenko

nielsenko commented Nov 24, 2025 •

Copy link
Copy Markdown
Collaborator

@mathis6787 Thank you for taking the time to consider my suggestion. A simple callback is indeed too simple. I like your S3Overrides object, but I would like you to also encapsulated the actual endpointUrl calculation in that, and have a default version for regular AWS S3. Does that make sense?

@mathis6787
mathis6787 requested a review from nielsenko November 25, 2025 04:14
@mathis6787

Copy link
Copy Markdown
Contributor Author

Refactor S3 storage configuration with S3Overrides

Replaced multiple optional S3 configuration parameters (endpointUrl, host, useHttps) with a single S3Overrides object to improve API clarity and maintainability.

Changes

  • Created S3Overrides class to encapsulate endpoint configuration for S3-compatible storage
  • Refactored S3CloudStorage constructor to accept S3Overrides? instead of individual parameters
  • Updated AwsS3Uploader to require pre-built endpoint (removed internal _buildEndpointUrl)
  • S3Overrides handles endpoint URL normalization (supports with/without trailing slash)
  • Kept publicHost as separate parameter for flexibility

Usage

AWS S3 (unchanged behavior):

S3CloudStorage(
  serverpod: pod,
  storageId: 'default',
  region: 'us-east-1',
  bucket: 'my-bucket',
  public: true,
)

MinIO/S3-compatible:

S3CloudStorage(
  serverpod: pod,
  storageId: 'default',
  region: 'us-east-1',
  bucket: 'my-bucket',
  public: false,
  overrides: S3Overrides(
    endpointUrl: 'http://localhost:9000',
    host: 'localhost:9000',
    useHttps: false,
  ),
)

Tested with MinIO and with AWS S3.

@nielsenko nielsenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I had more urgent tasks on my plate.

I took another look. I would like you to consider making S3Options a pure interface (perhaps think a bit about the name). Also, I would like you to adopt a similar approach on the client side to avoid a breaking change.

Do you agree to these suggestions?

@mathis6787

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!
I applied the requested changes:

  • Introduced change S3Overrides for S3Options and changed it to an abstract class.
  • Added AwsS3Options and MinioS3Options as concrete implementations.
  • Remove required for endpoint in AWsUploader
  • Cleaned up the redundant toString() usage.

I hope this aligns with what you had in mind

@mathis6787

Copy link
Copy Markdown
Contributor Author

@nielsenko
Any update ?

@nielsenko

Copy link
Copy Markdown
Collaborator

@mathis6787 Sorry for the delay. I do have a pending review, but the race to release 3.0 took precedence. I'm currently on vacation, but will return in the new year.

@nielsenko

Copy link
Copy Markdown
Collaborator

@mathis6787 We decided to do an overhaul of the storage implementations in 3.4. You may want to try building your min-io integration on top.

@mathis6787

Copy link
Copy Markdown
Contributor Author

Your new package works very well with s3 Compat. I am closing this PR

@mathis6787 mathis6787 closed this Mar 6, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants