Browse Source

Merge pull request #24 from toranger/master

rm the panic in interface
tags/v0.7.8
toranger 6 years ago
committed by GitHub
parent
commit
85d2492d05
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      object.go

10
object.go

@ -402,7 +402,7 @@ func (s *ObjectService) MultiUpload(ctx context.Context, name string, r io.Reade
optini := opt.OptIni optini := opt.OptIni
res, _, err := s.InitiateMultipartUpload(ctx, name, optini) res, _, err := s.InitiateMultipartUpload(ctx, name, optini)
if err != nil { if err != nil {
panic(err)
return nil, nil, err
} }
uploadID := res.UploadID uploadID := res.UploadID
bufSize := opt.PartSize * 1024 * 1024 bufSize := opt.PartSize * 1024 * 1024
@ -416,10 +416,7 @@ func (s *ObjectService) MultiUpload(ctx context.Context, name string, r io.Reade
fmt.Println(err) fmt.Println(err)
} }
}() }()
resp, err := s.UploadPart(context.Background(), name, uploadId, partNumber, data, nil)
if err != nil {
panic(err)
}
resp, _ := s.UploadPart(context.Background(), name, uploadId, partNumber, data, nil)
ch <- resp ch <- resp
} }
@ -429,7 +426,7 @@ func (s *ObjectService) MultiUpload(ctx context.Context, name string, r io.Reade
bytesread, err := r.Read(buffer) bytesread, err := r.Read(buffer)
if err != nil { if err != nil {
if err != io.EOF { if err != io.EOF {
panic(err)
return nil, nil, err
} }
PartNumber = i PartNumber = i
break break
@ -440,6 +437,7 @@ func (s *ObjectService) MultiUpload(ctx context.Context, name string, r io.Reade
for i := 1; i < PartNumber; i++ { for i := 1; i < PartNumber; i++ {
resp := <-chs[i] resp := <-chs[i]
// Notice one part fail can not get the etag according.
etag := resp.Header.Get("ETag") etag := resp.Header.Get("ETag")
optcom.Parts = append(optcom.Parts, Object{ optcom.Parts = append(optcom.Parts, Object{
PartNumber: i, ETag: etag}, PartNumber: i, ETag: etag},

Loading…
Cancel
Save