parent
e83fb85216
commit
e8b96ada11
|
|
@ -52,10 +52,10 @@ type Dfstore interface {
|
||||||
GetObjectWithContext(ctx context.Context, input *GetObjectInput) (io.ReadCloser, error)
|
GetObjectWithContext(ctx context.Context, input *GetObjectInput) (io.ReadCloser, error)
|
||||||
|
|
||||||
// PutObjectRequestWithContext returns *http.Request of putting object.
|
// PutObjectRequestWithContext returns *http.Request of putting object.
|
||||||
PutObjectRequestWithContext(ctx context.Context, input *PutOjectInput) (*http.Request, error)
|
PutObjectRequestWithContext(ctx context.Context, input *PutObjectInput) (*http.Request, error)
|
||||||
|
|
||||||
// PutObjectWithContext puts data of object.
|
// PutObjectWithContext puts data of object.
|
||||||
PutObjectWithContext(ctx context.Context, input *PutOjectInput) error
|
PutObjectWithContext(ctx context.Context, input *PutObjectInput) error
|
||||||
|
|
||||||
// DeleteObjectRequestWithContext returns *http.Request of deleting object.
|
// DeleteObjectRequestWithContext returns *http.Request of deleting object.
|
||||||
DeleteObjectRequestWithContext(ctx context.Context, input *DeleteObjectInput) (*http.Request, error)
|
DeleteObjectRequestWithContext(ctx context.Context, input *DeleteObjectInput) (*http.Request, error)
|
||||||
|
|
@ -257,8 +257,8 @@ func (dfs *dfstore) GetObjectWithContext(ctx context.Context, input *GetObjectIn
|
||||||
return resp.Body, nil
|
return resp.Body, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutOjectInput is used to construct request of putting object.
|
// PutObjectInput is used to construct request of putting object.
|
||||||
type PutOjectInput struct {
|
type PutObjectInput struct {
|
||||||
// BucketName is bucket name.
|
// BucketName is bucket name.
|
||||||
BucketName string
|
BucketName string
|
||||||
|
|
||||||
|
|
@ -282,8 +282,8 @@ type PutOjectInput struct {
|
||||||
Reader io.Reader
|
Reader io.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates PutOjectInput fields.
|
// Validate validates PutObjectInput fields.
|
||||||
func (i *PutOjectInput) Validate() error {
|
func (i *PutObjectInput) Validate() error {
|
||||||
if i.BucketName == "" {
|
if i.BucketName == "" {
|
||||||
return errors.New("invalid BucketName")
|
return errors.New("invalid BucketName")
|
||||||
|
|
||||||
|
|
@ -305,7 +305,7 @@ func (i *PutOjectInput) Validate() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutObjectRequestWithContext returns *http.Request of putting object.
|
// PutObjectRequestWithContext returns *http.Request of putting object.
|
||||||
func (dfs *dfstore) PutObjectRequestWithContext(ctx context.Context, input *PutOjectInput) (*http.Request, error) {
|
func (dfs *dfstore) PutObjectRequestWithContext(ctx context.Context, input *PutObjectInput) (*http.Request, error) {
|
||||||
if err := input.Validate(); err != nil {
|
if err := input.Validate(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -360,7 +360,7 @@ func (dfs *dfstore) PutObjectRequestWithContext(ctx context.Context, input *PutO
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutObjectWithContext puts data of object.
|
// PutObjectWithContext puts data of object.
|
||||||
func (dfs *dfstore) PutObjectWithContext(ctx context.Context, input *PutOjectInput) error {
|
func (dfs *dfstore) PutObjectWithContext(ctx context.Context, input *PutObjectInput) error {
|
||||||
req, err := dfs.PutObjectRequestWithContext(ctx, input)
|
req, err := dfs.PutObjectRequestWithContext(ctx, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ func (mr *MockDfstoreMockRecorder) IsObjectExistWithContext(ctx, input interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutObjectRequestWithContext mocks base method.
|
// PutObjectRequestWithContext mocks base method.
|
||||||
func (m *MockDfstore) PutObjectRequestWithContext(ctx context.Context, input *dfstore.PutOjectInput) (*http.Request, error) {
|
func (m *MockDfstore) PutObjectRequestWithContext(ctx context.Context, input *dfstore.PutObjectInput) (*http.Request, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "PutObjectRequestWithContext", ctx, input)
|
ret := m.ctrl.Call(m, "PutObjectRequestWithContext", ctx, input)
|
||||||
ret0, _ := ret[0].(*http.Request)
|
ret0, _ := ret[0].(*http.Request)
|
||||||
|
|
@ -173,7 +173,7 @@ func (mr *MockDfstoreMockRecorder) PutObjectRequestWithContext(ctx, input interf
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutObjectWithContext mocks base method.
|
// PutObjectWithContext mocks base method.
|
||||||
func (m *MockDfstore) PutObjectWithContext(ctx context.Context, input *dfstore.PutOjectInput) error {
|
func (m *MockDfstore) PutObjectWithContext(ctx context.Context, input *dfstore.PutObjectInput) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "PutObjectWithContext", ctx, input)
|
ret := m.ctrl.Call(m, "PutObjectWithContext", ctx, input)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ func copyLocalFileToObjectStorage(ctx context.Context, cfg *config.DfstoreConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
tr := io.TeeReader(f, bar)
|
tr := io.TeeReader(f, bar)
|
||||||
if err := dfstore.New(cfg.Endpoint).PutObjectWithContext(ctx, &dfstore.PutOjectInput{
|
if err := dfstore.New(cfg.Endpoint).PutObjectWithContext(ctx, &dfstore.PutObjectInput{
|
||||||
BucketName: bucketName,
|
BucketName: bucketName,
|
||||||
ObjectKey: objectKey,
|
ObjectKey: objectKey,
|
||||||
Filter: cfg.Filter,
|
Filter: cfg.Filter,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue