feat: add overrideHost/Port/Scheme to presigned URL methods#111
Open
hammadparveez wants to merge 2 commits intoxtyxtyx:masterfrom
Open
feat: add overrideHost/Port/Scheme to presigned URL methods#111hammadparveez wants to merge 2 commits intoxtyxtyx:masterfrom
hammadparveez wants to merge 2 commits intoxtyxtyx:masterfrom
Conversation
Replace int.parse with int.tryParse when reading the content-length response header in statObject. The header is not guaranteed to be present; the null-check operator caused an unhandled crash. Using tryParse with a null-coalescing fallback returns null gracefully, which matches the already-nullable int? size field on StatObjectResult. Fixes xtyxtyx#108 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
) In multi-network architectures the MinIO client connects to an internal endpoint, but presigned URLs distributed to external clients must use the public-facing host, port, and/or scheme. Without these overrides a separate Minio instance would have to be created just for URL generation. Add three optional named parameters to presignedUrl(), presignedGetObject(), and presignedPutObject(): - overrideHost (String?) - overridePort (int?) - overrideScheme (String?) When any override is provided the request URL and its host header are replaced before signing, so the resulting presigned URL is valid for the external endpoint. All existing tests continue to pass. New tests verify that each override parameter (and all three together) are reflected in the generated URL for both GET and PUT methods. Closes xtyxtyx#101
There was a problem hiding this comment.
Pull request overview
Adds the ability to override the host/port/scheme used when generating presigned URLs so that a client can talk to an internal MinIO endpoint while distributing externally-valid presigned URLs.
Changes:
- Add optional
overrideHost,overridePort, andoverrideSchemenamed parameters topresignedUrl(),presignedGetObject(), andpresignedPutObject(). - Apply URL +
Hostheader overrides prior to SigV4 presigning. - Extend presigned URL unit tests to assert URL components reflect overrides.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/src/minio.dart | Adds override parameters and rewrites the request URL/host header before calling SigV4 presign logic. |
| test/minio_presigned_url_test.dart | Adds tests asserting the generated presigned URL reflects override host/port/scheme. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #101
In multi-network setups the MinIO client connects to an internal endpoint (e.g.
http://internal-minio:9000), but presigned URLs distributed to external users must point to the public-facing address. Previously there was no way to customise the host/port/scheme of a presigned URL without instantiating a separateMinioclient.This PR adds three optional named parameters to
presignedUrl(),presignedGetObject(), andpresignedPutObject():overrideHostString?overridePortint?overrideSchemeString?http/https)All three are independent and optional — omitting one keeps the value from the client configuration. When any override is present, both the URL and the
hostheader are updated before signing, so the resulting URL is fully valid for the external endpoint.Usage example
Changes
lib/src/minio.dart— added parameters topresignedUrl,presignedGetObject,presignedPutObjecttest/minio_presigned_url_test.dart— 6 new unit tests covering each override param and combined usageTest plan
overrideHost,overridePort,overrideSchemeindividually and combined for both GET and PUT