feat(infra): support uploading files via io.Reader (#1793)

This commit is contained in:
Ryo
2025-08-25 18:25:12 +08:00
committed by GitHub
parent 6fa2acf05a
commit 14ce6bc112
6 changed files with 115 additions and 36 deletions

View File

@@ -38,6 +38,7 @@ type PutOption struct {
ContentDisposition *string
ContentLanguage *string
Expires *time.Time
ObjectSize int64
}
type PutOptFn func(option *PutOption)
@@ -48,6 +49,12 @@ func WithContentType(v string) PutOptFn {
}
}
func WithObjectSize(v int64) PutOptFn {
return func(o *PutOption) {
o.ObjectSize = v
}
}
func WithContentEncoding(v string) PutOptFn {
return func(o *PutOption) {
o.ContentEncoding = &v

View File

@@ -16,11 +16,15 @@
package storage
import "context"
import (
"context"
"io"
)
//go:generate mockgen -destination ../../../internal/mock/infra/contract/storage/storage_mock.go -package mock -source storage.go Factory
type Storage interface {
PutObject(ctx context.Context, objectKey string, content []byte, opts ...PutOptFn) error
PutObjectWithReader(ctx context.Context, objectKey string, content io.Reader, opts ...PutOptFn) error
GetObject(ctx context.Context, objectKey string) ([]byte, error)
DeleteObject(ctx context.Context, objectKey string) error
GetObjectUrl(ctx context.Context, objectKey string, opts ...GetOptFn) (string, error)