81 Commits
Author SHA1 Message Date
ys-ll 3357c14e91 fix: support zero-byte uploads in FilePut
Reading the body into a zero-length buffer returned io.EOF on an
already-exhausted reader, so empty files and directory markers always
failed. Use io.ReadFull and send an explicit Content-Length: 0 for
empty bodies instead of falling back to chunked encoding. Also fix an
error variable mix-up in the NewRequest error check.
2026-09-30 16:18:31 +08:00
ys-ll 9210db974c feat: add UseVirtualHostedStyle flag for S3-compatible services
S3-compatible services such as Alibaba Cloud OSS, Tencent COS and
Huawei OBS reject path-style URLs with 'SecondLevelDomainForbidden'
and only accept virtual-hosted style (https://bucket.endpoint/key).

This adds a UseVirtualHostedStyle field and SetVirtualHostedStyle()
setter. When enabled and a custom Endpoint is set, the first path
segment is treated as the bucket and prepended to the host as a
subdomain. AWS S3 and MinIO accept both styles, so this is a no-op
for them.

Includes tests for OSS-style endpoint, http/https scheme preservation
and the empty-path fallback used by ListBuckets-style operations.
2026-08-01 23:42:15 +08:00
zhanglq 1d8c6e314b fix: use path.Clean instead of filepath.Clean for cross-platform URI canonicalization
filepath.Clean converts forward slashes to backslashes on Windows,
which breaks the AWS V4 signature calculation by corrupting the
canonical URI. Use path.Clean which always uses forward slashes,
matching the S3 API expectation.
2026-07-02 14:55:57 +08:00
Naphat Amundsen 57fa0ece6f Fix issue presigning request with custom headers, also fix small deviation from spec related to lower case headers (#35)
Fix presigned URLs with custom headers (e.g., Content-Length) by:

1. Always URI-encoding query parameter values (removes incorrect special case for X-Amz-SignedHeaders)
2. Lowercasing header names per AWS Signature V4 spec

Fixes SignatureDoesNotMatch errors with Cloudflare R2 and other strict S3-compatible services.

PR: #35
Author: @Napam
2026-01-23 12:29:56 +05:30
Rohan Verma f02c375b6d style: go fmt cleanup 2025-11-27 17:36:39 +05:30
Rohan Verma 0471a404a8 docs: adjust future roadmap version numbers 2025-11-27 17:35:32 +05:30
Rohan Verma bb8ace290c docs: update roadmap for v0.11.0 release 2025-11-27 17:35:12 +05:30
Rohan Verma 0f57456b2a feat: add server-side encryption support
Implements server-side encryption capabilities (v0.13.0) including:
- Core Support: SSE-S3 (AES256) and SSE-KMS
- Integration: Added encryption fields to UploadInput, CopyObjectInput, InitiateMultipartUploadInput, and MultipartUploadInput
- Operations: Updated FilePut, FileUpload (POST), CopyObject, and multipart upload flows to support encryption headers
- API: Updated FileDetails (HeadObject) to return ServerSideEncryption and SSEKMSKeyId in DetailsResponse

Testing:
- Configured MinIO with built-in KMS (via MINIO_KMS_SECRET_KEY) in docker-compose.yml to enable SSE-S3 support
- Added comprehensive integration tests verifying headers are correctly sent and returned
- Verified file integrity and encryption status across all upload methods

Updated ROADMAP.md to mark v0.13.0 as completed.
2025-11-27 17:26:03 +05:30
Rohan Verma b43fd913ed feat: add ACL and Lifecycle support
Implements ACL and Lifecycle management capabilities (v0.16.0) including:
- Bucket APIs: PutBucketAcl, GetBucketAcl, PutBucketLifecycle, GetBucketLifecycle, DeleteBucketLifecycle
- Object APIs: PutObjectAcl, GetObjectAcl
- Integration: Support for Canned ACLs (private, public-read, etc.) and Full Access Control Policies
- Lifecycle Configuration: Rules, Filters, Expiration, Transitions

Verified integration with MinIO:
- Note: MinIO returns 501 Not Implemented for Canned ACLs via headers, so tests for those are skipped while Custom ACLs (XML) are fully verified.

Includes comprehensive integration tests covering all operations.
Updated ROADMAP.md to mark v0.16.0 as completed.
2025-11-27 17:04:27 +05:30
Rohan Verma 9219b63613 feat: add object versioning support
Implements object versioning capabilities (v0.15.0) including:
- Bucket APIs: PutBucketVersioning, GetBucketVersioning
- Object Listing: ListVersions (lists versions and delete markers)
- Object Operations: Updated FileDownload, FileDelete, and FileDetails to support VersionId
- Integration tests covering the full versioning workflow (enable, upload versions, list, download specific version, delete specific version)

Documentation updated in README.md and ROADMAP.md.

"I have implemented Object Versioning (v0.15.0) as per the roadmap."
2025-11-27 16:48:58 +05:30
Rohan Verma 11cad3573f feat: add object tagging support
Implements object tagging capabilities (v0.14.0) including:
- Core APIs: PutObjectTagging, GetObjectTagging, DeleteObjectTagging
- Integration with FilePut, FileUpload, and CopyObject operations
- Helper functions for URL-encoded tag header formatting
- Comprehensive input validation (max 10 tags, required fields)

Addresses specific compatibility issues with MinIO and Cloudflare R2:
- Implements a 2-step workaround for CopyObject (copy first, then tag) to avoid SignatureDoesNotMatch errors caused by the x-amz-tagging-directive header on non-AWS providers.

Includes comprehensive integration tests and documentation updates.
2025-11-27 16:14:32 +05:30
Rohan Verma ba9ef916bc feat: add multipart upload support
"Verify the multipart upload implementation works correctly by running integration tests against MinIO and validating file integrity, parallel uploads, and error handling."

Core APIs:
- Add InitiateMultipartUpload for starting multipart uploads
- Add UploadPart for uploading individual parts (5MB-5GB)
- Add CompleteMultipartUpload to finalize uploads
- Add AbortMultipartUpload to cancel and cleanup uploads
- Add ListParts to query uploaded parts

High-Level Features:
- Add FileUploadMultipart API with automatic chunking
- Add uploadPartWithRetry with exponential backoff (3 retries default)
- Add parallel upload worker pool with configurable concurrency
- Add progress callbacks for real-time upload tracking
- Add GeneratePresignedUploadPartURL for browser-based uploads

Advanced Features:
- Automatic file chunking with configurable part sizes (5MB-5GB)
- Parallel upload worker pool with configurable concurrency
- Retry logic with exponential backoff (configurable retries)
- Real-time progress tracking with upload speed calculation
- Automatic cleanup on errors via AbortMultipartUpload
- Support for resumable uploads via ListParts
- Comprehensive input validation for all parameters
- File integrity verification across all upload modes

Testing:
- Add comprehensive integration tests (500+ lines)
- Test sequential uploads (15MB, 3 parts, ~45 MB/s)
- Test parallel uploads (20MB, 4 parts, concurrency=3)
- Test small files (3MB, single part)
- Validate abort and ListParts functionality
- Test input validation and error cases
- Verify file integrity with hash comparison
- All tests passing against MinIO

Documentation:
- Update README with multipart upload examples
- Add high-level and low-level API usage
- Document browser-based multipart uploads
- Mark multipart upload implementation as complete in ROADMAP
- Update gitignore to exclude *.bin and test-output.log

Verified against MinIO with complete test coverage.
2025-11-27 02:16:16 +05:30
Rohan Verma 9a14996a0b feat: add CopyObject and DeleteObjects operations
Implements object manipulation capabilities for v0.11.0:
- CopyObject: server-side copy within/across buckets with metadata control
- DeleteObjects: batch delete up to 1000 objects in single request

Both operations follow AWS S3 API specification with proper:
- AWS Signature V4 signing
- XML request/response handling
- Content-MD5 and SHA256 headers
- Comprehensive input validation

Fixed DeleteObjects signature mismatch with MinIO by correcting the canonical
query string format for empty query parameter values (delete= instead of delete).
The writeQuery function now properly appends = to keys with empty values per
AWS Signature V4 specification.

CopyObject enables CLI mv commands. DeleteObjects enables efficient
batch operations for CLI sync/rm.

Tests: All CopyObject and DeleteObjects tests passing with MinIO.

"lets work on the object level operations"
2025-11-27 01:18:57 +05:30
Rohan Verma e410cc846e feat: add bucket operations (ListBuckets, CreateBucket, DeleteBucket)
Adds bucket management capabilities:
- ListBuckets: list all buckets for AWS account with owner info
- CreateBucket: create bucket with optional region support
- DeleteBucket: delete empty buckets

Includes comprehensive tests and README documentation.

Prompt: "Please review the changes we have made for this bucket api"
2025-11-26 21:11:00 +05:30
Rohan Verma 2334cb5429 refactor: split simples3.go into logical modules
Split monolithic simples3.go (1064 LOC) into 5 focused modules:
- simples3.go (141 LOC) - Core S3 struct and configuration
- helpers.go (97 LOC) - Utility functions
- iam.go (202 LOC) - IAM credential handling
- list.go (260 LOC) - List operations
- object.go (409 LOC) - File operations

Split simples3_test.go (912 LOC) into 4 test modules:
- simples3_test.go (118 LOC) - Shared test helpers
- iam_test.go (110 LOC) - IAM tests
- list_test.go (321 LOC) - List operation tests
- object_test.go (381 LOC) - File operation tests

Zero functional changes. All tests pass identically. 72.5% test coverage maintained.

"Review v0.10.2 code refactor"
2025-11-26 14:57:15 +05:30
Rohan Verma 61124858fb docs: improve README clarity and add project roadmap
"we never used to have like so many emojis earlier and the look of the readme on github was really professional. can you please fix that"
"can you critique the readme"

- Remove emojis from features list and code examples for professional appearance
- Fix error handling in Quick Start example
- Add proper error checks for io.ReadAll
- Fix escaped newlines in printf statements (\\n to \n)
- Remove confusing SetEndpoint line from Quick Start
- Add ROADMAP.md with planned features through v1.0.0
- Update Contributing section to reference ROADMAP.md
2025-11-26 13:40:36 +05:30
Abhinav Raut 171b6756e1 feat: Add support for response-content-disposition in presigned URLs (#34)
* feat: add support for response-content-disposition in presigned URLs
- minor refactors

* remove extra comments
2025-11-26 12:31:22 +05:30
Rohan Verma 80ea209c04 Merge pull request #33 from rhnvrm/feat-listobjects-v2
feat: implement Simple List API for S3 objects
2025-09-23 10:38:56 +05:30
Rohan Verma d92dedd08d feat: add ListAll iterator method for Go 1.23+ pagination 2025-09-23 10:14:51 +05:30
Rohan Verma f661a85ff3 feat: implement Simple List API for S3 objects
- Add List method with ListInput and ListResponse structs following simples3 patterns
- Implement pagination, prefix filtering, and delimiter grouping
- Add comprehensive test suite for List functionality
- Update tests to use environment variables instead of hardcoded values
- Fix deprecated io/ioutil usage throughout codebase
- Add comprehensive README with API documentation and examples
- Add Nix development environment with flake.nix
- Add Justfile for modern command runner
- Add Docker Compose setup for local MinIO testing
- Update GitHub Actions to use Nix and Justfile for CI consistency
- Fix test naming and setup flow issues

New API:
s3.List(ListInput{
    Bucket: "my-bucket",
    Prefix: "documents/",
    MaxKeys: 100,
})

All tests pass with new simplified API design.
2025-09-18 16:17:08 +05:30
Rohan Verma e5f20476ea Merge pull request #32 from abhinavxd/patch-1
fix: expired token error while generating presigned URLs
2025-09-18 00:07:32 +05:30
Abhinav Raut aa72271c58 Fix expired token error while generating presigned URLs
Adds renewIAMToken() call in GeneratePresignedURL.

On token expiry, GeneratePresignedURL would not renew it until
other methods that renew tokens are called.
2025-09-17 22:50:51 +05:30
Rohan Verma 59a29ac4b1 Merge pull request #31 from joicemjoseph/hotfix/iam-imds2-token-renewal
hotfix: corrects renewal logic
2025-06-04 15:20:20 +05:30
Joice M. Joseph 8506229515 hotfix: corrects renewal logic 2025-06-04 12:50:45 +05:30
Rohan Verma da717474cb Merge pull request #28 from nemunaire/b/signedurl_for_custom_endpoint
Rework presign function to allow signature of clients with dedicated endpoint
2025-04-23 23:25:19 +05:30
Rohan Verma 083b5555cc Merge pull request #30 from joicemjoseph/feat/expiry-check-on-iam
Adds check on token expiry; renews the token if expired
2025-04-23 23:24:42 +05:30
Joice M. Joseph 82001077bb Adds check on token expiry; renews the token if expired 2025-02-13 22:44:50 +05:30
Pierre-Olivier Mercier bb9a56dda9 Rework presign to allow signature of endpoint given clients 2024-08-23 15:59:06 +02:00
Rohan Verma 4257c79c4f Merge branch 'develop' 2024-07-09 12:36:56 +05:30
Rohan Verma a9c81a0e9c Merge branch 'imdsv2-support' into develop 2024-07-03 16:26:57 +05:30
Rohan Verma 1cf2d7d250 fix: add tests for imdsv2 2024-07-03 16:19:50 +05:30
Chinmay D. Pai 430bffb2e2 chore: send useIMDSv2 bool from fetchIMDSToken method
Instead of using the errors to figure out whether IMDSv2 needs to be used,
we return a boolean value for useIMDSv2 from the function itself, and
propagate the error to upstream function calls in the library.

IMDSv2 tokens can be used in all cases, even when IMDSv2 is set to `Optional`
in the EC2 Instance configuration. As such, calls with token will not fail and
we should be able to send IMDSv2 requests with token even when using IMDSv1.

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2024-07-03 13:29:48 +05:30
Chinmay D. Pai 547dfa8756 feat: add support for IMDSv2
Currently, IMDSv2 is not supported by simple-s3's `NewUsingIAM` method, causing it
to fail on EC2 instances with IMDSv2 enabled in the EC2 metadata configuration.

This patch adds a failsafe method that executes PUT request on the IMDSv2 token endpoint,
and based on the response decides whether IMDSv2 support needs to be enabled. Doing so
will not break or require any code-level changes to existing deployments, and allows the
same binaries to run on both IMDSv2 enabled and optional instances.

ref: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-metadata-v2-how-it-works.html

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2024-06-29 00:52:18 +05:30
Rohan Verma 046c5f5514 Merge pull request #25 from rhnvrm/fix-security-token
fix: set token header if available
2022-07-11 11:04:56 +05:30
Rohan b051044f8c fix: set token header if available
Closes #24
2022-07-11 11:03:42 +05:30
Rohan Verma 1c0e12c925 Merge pull request #21 from rhnvrm/feat-do-support
feat: add support for DigitalOcean
2022-02-22 11:26:07 +05:30
Rohan de82585958 feat: add support for DigitalOcean
This commit adds a x-amz-date header which is an undocumented
requirement of DO API requests.
2022-02-21 10:14:17 +05:30
Rohan Verma fa36dbb143 Merge pull request #20 from rhnvrm/feat-iam-isolate
feat: add support for timeout and customization in IAM setup.
2022-01-08 15:33:44 +05:30
Rohan 66870855b7 feat: add support for timeout and customization in IAM setup.
This commit adds a defaultHTTPClient to have a timeout of 10s
instead of the one provided by Go. It introduces a few new methods such
as
- FetchAndSetIAMData which is a helper method to be able to use the
custom http client set by the user.

Closes #19
2022-01-07 10:53:21 +05:30
Rohan Verma ad0419ef77 Merge pull request #18 from rhnvrm/feat-file-put
feat: add support for FilePut
2021-12-29 15:02:42 +05:30
Rohan a9d0bbf9a8 feat: add support for FilePut 2021-12-29 13:59:45 +05:30
Rohan Verma b23aec1a12 Merge pull request #15 from rhnvrm/develop
Support for Custom Metadata in FileUpload and fetching FileDetails
2021-07-19 13:43:27 +05:30
Rohan Verma eac235b2b6 feat: add support for FileDetails/HEAD API call (#14) 2021-07-19 13:41:36 +05:30
Joice 2a57ff9944 feat: Adds support for custom metadata (#13)
* feat: Adds support for custom metadata

assigning metadata for files will be beneficial to
find files.
ref: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/add-origin-custom-headers.html

* fix: review suggestions by @rhnvrm

- metadata moved to UploadInput as optional field.
- changed x-amz-meta as constant
- changed sprintf to simple string concat

* FIX: changed amazon meta prefix

changed variable name for amazon meta prefix to the top,
prefix variable is exported.
removed redundant comment for metadata
2021-07-19 12:46:49 +05:30
Rohan Verma 35d7b10832 fix: minor doc changes 2021-07-19 12:33:48 +05:30
Rohan Verma 7977285b10 chore: remove debug flag in aws command 2021-02-09 19:19:49 +05:30
Rohan Verma c7b8d45858 chore: add github actions (#12) 2021-02-09 19:18:31 +05:30
Rohan Verma c344c52b27 Merge pull request #11 from jacksgt/url-encoding
Fix URL encoding issue for filenames with special characters
2021-02-03 21:27:58 +05:30
Jack Henschel bf02e3bacf fix: Ensure trailing slash in CustomEndpoint is handled gracefully 2021-02-03 17:48:04 +02:00
Jack Henschel b42d2b1f1e docs: Make bucket references in README example consistent 2021-02-03 17:47:51 +02:00