feat(infra): support uploading files via io.Reader (#1793)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user