Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7539b5db24 | |||
| 862ec3f7bc |
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.3.0] - 2026-04-16
|
||||||
|
|
||||||
|
### 🚀 Features
|
||||||
|
|
||||||
|
- Add PresignInlineURL method for inline content display (#97)
|
||||||
|
|
||||||
## [0.2.0] - 2026-04-16
|
## [0.2.0] - 2026-04-16
|
||||||
|
|
||||||
### 🚀 Features
|
### 🚀 Features
|
||||||
|
|||||||
@@ -105,6 +105,25 @@ func (s *S3) PresignURL(ctx context.Context, key string) (string, error) {
|
|||||||
return req.URL, nil
|
return req.URL, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PresignInlineURL generates a presigned URL that tells the browser to display
|
||||||
|
// the content inline rather than triggering a download. The URL is valid for
|
||||||
|
// 15 minutes.
|
||||||
|
func (s *S3) PresignInlineURL(ctx context.Context, key string, contentType string) (string, error) {
|
||||||
|
input := &s3.GetObjectInput{
|
||||||
|
Bucket: aws.String(s.bucket),
|
||||||
|
Key: aws.String(key),
|
||||||
|
ResponseContentDisposition: aws.String("inline"),
|
||||||
|
}
|
||||||
|
if contentType != "" {
|
||||||
|
input.ResponseContentType = aws.String(contentType)
|
||||||
|
}
|
||||||
|
req, err := s.presigner.PresignGetObject(ctx, input, s3.WithPresignExpires(15*time.Minute))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return req.URL, nil
|
||||||
|
}
|
||||||
|
|
||||||
// New creates a new S3 storage instance using the upload manager
|
// New creates a new S3 storage instance using the upload manager
|
||||||
// This loads AWS config from the default locations and is suitable for most use cases
|
// This loads AWS config from the default locations and is suitable for most use cases
|
||||||
func New(bucket string) (*S3, error) {
|
func New(bucket string) (*S3, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user