Skip to content

Commit

Permalink
文件处理1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lilang committed Apr 18, 2023
1 parent a6573ca commit 3292425
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
37 changes: 32 additions & 5 deletions ci_fileprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type FileHashCodeResult struct {
type FileUncompressConfig struct {
Prefix string `xml:",omitempty"`
PrefixReplaced string `xml:",omitempty"`
UnCompressKey string `xml:",omitempty"`
}

type FileUncompressResult struct {
Expand All @@ -32,11 +33,13 @@ type FileUncompressResult struct {
}

type FileCompressConfig struct {
Flatten string `xml:",omitempty"`
Format string `xml:",omitempty"`
UrlList string `xml:",omitempty"`
Prefix string `xml:",omitempty"`
Key []string `xml:",omitempty"`
Flatten string `xml:",omitempty"`
Format string `xml:",omitempty"`
UrlList string `xml:",omitempty"`
Prefix string `xml:",omitempty"`
Key []string `xml:",omitempty"`
Type string `xml:",omitempty"`
CompressKey string `xml:",omitempty"`
}

type FileCompressResult struct {
Expand Down Expand Up @@ -148,3 +151,27 @@ func (s *CIService) GetFileHash(ctx context.Context, name string, opt *GetFileHa
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}

// ZipPreviewResult 压缩包预览结果
type ZipPreviewResult struct {
XMLName xml.Name `xml:"Response"`
FileNumber int `xml:"FileNumber,omitempty"`
Contents []*struct {
Key string `xml:"Key,omitempty"`
LastModified string `xml:"LastModified,omitempty"`
UncompressedSize int `xml:"UncompressedSize,omitempty"`
} `xml:"Contents,omitempty"`
}

// ZipPreview 压缩包预览
func (s *CIService) ZipPreview(ctx context.Context, name string) (*ZipPreviewResult, *Response, error) {
var res ZipPreviewResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(name) + "?ci-process=zippreview",
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}
19 changes: 19 additions & 0 deletions ci_fileprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,22 @@ func TestCIService_GetFileHash(t *testing.T) {
t.Fatalf("CI.GetFileHash returned error: %v", err)
}
}

func TestCIService_ZipPreview(t *testing.T) {
setup()
defer teardown()

name := "test.zip"
mux.HandleFunc("/"+name, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
v := values{
"ci-process": "zippreview",
}
testFormValues(t, r, v)
})

_, _, err := client.CI.ZipPreview(context.Background(), name)
if err != nil {
t.Fatalf("CI.ZipPreview returned error: %v", err)
}
}
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194 h1:Oho9ykiKXwOHkeq5jSAvlkBAcRwNqnrUca/5WacvH2E=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563 h1:2VDxTtn9dAqI2DnnvB9fXpPE4DblOmquyzmN2zxTD8A=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.194 h1:YB6qJyCPuwtHFr54/GAfYj1VfwhiDHnwtOKu40OaG2M=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.194/go.mod h1:yrBKWhChnDqNz1xuXdSbWXG56XawEq0G5j1lg4VwBD4=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=

0 comments on commit 3292425

Please sign in to comment.