feat(simplestorage): add Head method to Client#20
Conversation
Needed for implementing something in glue. Signed-off-by: Xe Iaso <xe@tigrisdata.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a Head method to the simplestorage Client, which is the equivalent of S3's HeadObject operation, allowing users to retrieve object metadata without downloading the content. It also adds a Metadata field to the Object struct to support custom metadata headers.
Changes:
- Added
Metadatafield to theObjectstruct to store custom metadata headers - Added
Headmethod toClientfor retrieving object metadata without downloading content - Updated
Getmethod to populate the newMetadatafield
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Bucket: o.BucketName, | ||
| Key: key, | ||
| ContentType: lower(resp.ContentType, "application/octet-stream"), | ||
| Etag: lower(resp.ETag, ""), | ||
| Size: lower(resp.ContentLength, 0), | ||
| Version: lower(resp.VersionId, ""), | ||
| LastModified: lower(resp.LastModified, time.Time{}), | ||
| Metadata: resp.Metadata, |
There was a problem hiding this comment.
The Head method doesn't populate the ContentDisposition field, which is available in the AWS S3 HeadObjectOutput response. For consistency with the Object struct definition and to match the AWS S3 API capabilities, consider adding ContentDisposition similar to how it's done for other fields. This would look like: ContentDisposition: lower(resp.ContentDisposition, "") in the Object initialization. Note that the Get method also doesn't populate this field, so fixing it here would be a good opportunity to establish the pattern, though fixing Get would be a separate concern.
| Bucket: o.BucketName, | |
| Key: key, | |
| ContentType: lower(resp.ContentType, "application/octet-stream"), | |
| Etag: lower(resp.ETag, ""), | |
| Size: lower(resp.ContentLength, 0), | |
| Version: lower(resp.VersionId, ""), | |
| LastModified: lower(resp.LastModified, time.Time{}), | |
| Metadata: resp.Metadata, | |
| Bucket: o.BucketName, | |
| Key: key, | |
| ContentType: lower(resp.ContentType, "application/octet-stream"), | |
| ContentDisposition: lower(resp.ContentDisposition, ""), | |
| Etag: lower(resp.ETag, ""), | |
| Size: lower(resp.ContentLength, 0), | |
| Version: lower(resp.VersionId, ""), | |
| LastModified: lower(resp.LastModified, time.Time{}), | |
| Metadata: resp.Metadata, |
The Head() method was not populating the ContentDisposition field, which is available in the S3 HeadObjectOutput response. This adds the field for consistency with the Object struct definition. Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
# [0.4.0](v0.3.0...v0.4.0) (2026-01-26) ### Features * **simplestorage:** add Head method to Client ([#20](#20)) ([3366180](3366180)) Signed-off-by: Tigris Data <social@tigrisdata.com>
|
🎉 This PR is included in version 0.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [0.4.0](v0.3.0...v0.4.0) (2026-01-26) ### Features * **simplestorage:** add Head method to Client ([#20](#20)) ([3366180](3366180)) Signed-off-by: Tigris Data <social@tigrisdata.com> Signed-off-by: Xe Iaso <xe@tigrisdata.com>
* chore(release): 0.4.0 # [0.4.0](v0.3.0...v0.4.0) (2026-01-26) ### Features * **simplestorage:** add Head method to Client ([#20](#20)) ([3366180](3366180)) Signed-off-by: Tigris Data <social@tigrisdata.com> Signed-off-by: Xe Iaso <xe@tigrisdata.com> * feat(simplestorage): add ClientOption functions for presigned URL headers - Add WithContentType() for setting Content-Type on PUT URLs - Add WithContentDisposition() for setting Content-Disposition on PUT URLs - Extend ClientOptions struct with ContentType and ContentDisposition fields Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <me@xeiaso.net> Signed-off-by: Xe Iaso <xe@tigrisdata.com> * test(simplestorage): add failing tests for PresignURL method - Add table-driven tests for GET, PUT, DELETE methods - Add validation tests for invalid inputs - Add tests for ContentType and ContentDisposition options Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> * feat(simplestorage): add PresignURL method with input validation - Add PresignURL method supporting GET, PUT, DELETE methods - Validate HTTP method returns error for unsupported methods - Validate key is non-empty - Validate expiry is positive - Build ClientOptions from functional options Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> * feat(simplestorage): implement GET presigned URL generation - Add presignURLGet helper using AWS SDK presign client - Wire GET method routing in PresignURL - Import s3/presigner package Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> * feat(simplestorage): implement PUT presigned URL generation - Add presignURLPut helper with ContentType and ContentDisposition support - Wire PUT method routing in PresignURL - Apply ClientOptions headers to presigned PUT URLs Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> * feat(simplestorage): implement DELETE presigned URL generation - Add presignURLDelete helper using AWS SDK presign client - Wire DELETE method routing in PresignURL - Complete presigned URL support for GET, PUT, DELETE Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> * docs(simplestorage): add usage examples for PresignURL - Add example for GET presigned URL (downloads) - Add example for PUT presigned URL (uploads with headers) - Add example for DELETE presigned URL (deletions) Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> * test(simplestorage): add actual validation testing to PresignURL tests - Tests now call PresignURL() for validation cases - Verify error messages contain expected substrings - Removes misleading skip message for already-implemented validation Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Claude Code <xe@tailscale.com> Signed-off-by: Xe Iaso <xe@tigrisdata.com> * docs: add presigned URL API implementation plan - Detailed plan for PresignURL method supporting GET, PUT, DELETE - 8 tasks covering implementation, tests, and documentation - Follows TDD approach with table-driven tests Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> * fix(simplestorage): use http.Method constants and add negative expiry test - Update examples to use http.MethodGet/Put/Delete constants - Add test case for negative expiry duration validation Assisted-by: GLM 4.7 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com> --------- Signed-off-by: Tigris Data <social@tigrisdata.com> Signed-off-by: Xe Iaso <xe@tigrisdata.com> Signed-off-by: Xe Iaso <me@xeiaso.net> Signed-off-by: Claude Code <xe@tailscale.com> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Summary
Details
The moral equivalent of HeadObject, but for package simplestorage.
Test plan
go build ./...npm run formatRelease-status: cut