Files
lincodex/backend/internal/port/outbound/object_storage.go
T

32 lines
975 B
Go

package outbound
import (
"context"
"errors"
"io"
)
var (
ErrObjectNotFound = errors.New("object not found")
ErrInvalidObject = errors.New("invalid object input")
ErrObjectStorage = errors.New("object storage request failed")
)
// Object contains a streaming response. The caller must close Body and keep the
// request context alive until reading is complete.
type Object struct {
Body io.ReadCloser
Size int64
ContentType string
}
type ObjectStorage interface {
// Put streams exactly size bytes. The caller owns the source reader and must
// ensure a blocking source can be canceled. An error may leave a completed
// object when the server accepted the write before the response was lost.
Put(ctx context.Context, key string, body io.Reader, size int64, contentType string) error
Get(ctx context.Context, key string) (Object, error)
// Delete succeeds when the object is already absent.
Delete(ctx context.Context, key string) error
}