Skip to content

fix:aws oss #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/file/s3/aws/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (a *AwsOss) Put(ctx context.Context, st *file.PutFileStu) error {
if err != nil {
return err
}
_, err = client.PutObject(context.TODO(), input, nil)
_, err = client.PutObject(context.TODO(), input)
if err != nil {
return err
}
Expand Down Expand Up @@ -171,7 +171,7 @@ func (a *AwsOss) Get(ctx context.Context, st *file.GetFileStu) (io.ReadCloser, e
if err != nil {
return nil, err
}
ob, err := client.GetObject(context.TODO(), input, nil)
ob, err := client.GetObject(context.TODO(), input)
if err != nil {
return nil, err
}
Expand All @@ -195,7 +195,7 @@ func (a *AwsOss) List(ctx context.Context, st *file.ListRequest) (*file.ListResp
if err != nil {
return nil, fmt.Errorf("list bucket[%s] fail, err: %s", st.DirectoryName, err.Error())
}
out, err := client.ListObjects(context.TODO(), input, nil)
out, err := client.ListObjects(context.TODO(), input)
if err != nil {
return nil, fmt.Errorf("list bucket[%s] fail, err: %s", st.DirectoryName, err.Error())
}
Expand Down
21 changes: 20 additions & 1 deletion components/file/s3/aws/oss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ func TestAwsOss_Put(t *testing.T) {

req.FileName = "/a.txt"
err = oss.Put(context.Background(), req)
assert.Equal(t, err.Error(), "awsoss put file[/a.txt] fail,err: invalid fileName format")
}

func TestAwsOss_Get(t *testing.T) {
oss := NewAwsOss()
err := oss.Init(context.TODO(), &file.FileConfig{Metadata: []byte(cfg)})
assert.Equal(t, nil, err)

putReq := &file.PutFileStu{
FileName: "layotto/get_test.txt",
}
err = oss.Put(context.Background(), putReq)

req := &file.GetFileStu{
FileName: "",
}
_, err = oss.Get(context.Background(), req)
assert.Equal(t, err.Error(), "awsoss get file[] fail,err: invalid fileName format")

req.FileName = "layotto/get_test.txt"
_, err = oss.Get(context.Background(), req)
//assert.Nil(t, , nil)
}