Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
修复bug,在使用分片上传时候,bucket.go的UploadObjectBySlice函数在打开文件后没有关闭,导致报too many…
Browse files Browse the repository at this point in the history
… open files错误
  • Loading branch information
wujianqiang committed Feb 23, 2018
1 parent 25626b5 commit 1ecc685
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions cos/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type ObjectSlice struct {
// 获得云存储上文件信息
func (b *Bucket) HeadObject(ctx context.Context, object string) error {
resq, err := b.conn.Do(ctx, "HEAD", b.Name, object, nil, nil, nil)
//fmt.Printf("%-18s: %d\n", "Content-Length", resq.ContentLength)
//fmt.Printf("%-18s: %s\n", "Content-Type", resq.c)
for k, v := range resq.Header {
value := fmt.Sprintf("%s", v)
fmt.Printf("%-18s: %s\n", k, strings.Replace(strings.Replace(value, "[", "", -1), "]", "", -1))
Expand Down Expand Up @@ -90,9 +88,9 @@ func (b *Bucket) UploadObjectBySlice(ctx context.Context, dst, src string, taskN
if err != nil {
return err
}
//fmt.Println(uploadID)

fd, err := os.Open(src)
defer fd.Close()
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cos/conf.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cos

const (
defaultPartSize = 60 * 1024 * 1024
defaultPartSize = 80 * 1024 * 1024
defaultRetryTimes = 3
defaultUA = "cos-go-sdk-v5.2.9"
defaultDomain = "myqcloud.com"
Expand Down
2 changes: 1 addition & 1 deletion cos/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (conn *Conn) Do(ctx context.Context, method, bucket, object string, params
if err != nil {
return nil, err
}
fmt.Println(url)
//fmt.Println(url)
conn.signHeader(req, params, headers)
req.Header.Set("User-Agent", conn.conf.UA)
req.Header.Set("Content-Length", strconv.FormatInt(req.ContentLength, 10))
Expand Down

0 comments on commit 1ecc685

Please sign in to comment.