Skip to content

feat(simplestorage): add Head method to Client#20

Merged
Xe merged 2 commits intomainfrom
Xe/add-head-method
Jan 26, 2026
Merged

feat(simplestorage): add Head method to Client#20
Xe merged 2 commits intomainfrom
Xe/add-head-method

Conversation

@Xe
Copy link
Copy Markdown
Collaborator

@Xe Xe commented Jan 26, 2026

Summary

  • Added fields to

Details

The moral equivalent of HeadObject, but for package simplestorage.

Test plan

  • Code compiles with go build ./...
  • Code formatted with npm run format
  • Manual testing

Release-status: cut

Needed for implementing something in glue.

Signed-off-by: Xe Iaso <xe@tigrisdata.com>
@Xe Xe self-assigned this Jan 26, 2026
Copilot AI review requested due to automatic review settings January 26, 2026 19:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Metadata field to the Object struct to store custom metadata headers
  • Added Head method to Client for retrieving object metadata without downloading content
  • Updated Get method to populate the new Metadata field

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread simplestorage/client.go Outdated
Comment on lines +233 to +240
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,
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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,

Copilot uses AI. Check for mistakes.
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>
@Xe Xe merged commit 3366180 into main Jan 26, 2026
8 checks passed
Xe pushed a commit that referenced this pull request Jan 26, 2026
# [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>
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 0.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Xe pushed a commit that referenced this pull request Jan 30, 2026
# [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>
Xe added a commit that referenced this pull request Jan 30, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants