fix oss: got 403 in TestContinueStreamAppendLarge
Signed-off-by: tgic <farmer1992@gmail.com>
This commit is contained in:
parent
9627c6c5a5
commit
2a8535626f
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
@ -46,11 +46,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/denverdino/aliyungo/oss",
|
"ImportPath": "github.com/denverdino/aliyungo/oss",
|
||||||
"Rev": "641bb4f0ddb552750324cb54c0140ca08865abd0"
|
"Rev": "0e0f322d0a54b994dea9d32541050d177edf6aa3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/denverdino/aliyungo/util",
|
"ImportPath": "github.com/denverdino/aliyungo/util",
|
||||||
"Rev": "641bb4f0ddb552750324cb54c0140ca08865abd0"
|
"Rev": "0e0f322d0a54b994dea9d32541050d177edf6aa3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/tarsum",
|
"ImportPath": "github.com/docker/docker/pkg/tarsum",
|
||||||
|
8
Godeps/_workspace/src/github.com/denverdino/aliyungo/oss/multi.go
generated
vendored
8
Godeps/_workspace/src/github.com/denverdino/aliyungo/oss/multi.go
generated
vendored
@ -139,6 +139,9 @@ func (b *Bucket) InitMulti(key string, contType string, perm ACL, options Option
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObjectResult, Part, error) {
|
func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObjectResult, Part, error) {
|
||||||
|
// TODO source format a /BUCKET/PATH/TO/OBJECT
|
||||||
|
// TODO not a good design. API could be changed to PutPartCopyWithinBucket(..., path) and PutPartCopyFromBucket(bucket, path)
|
||||||
|
|
||||||
headers := make(http.Header)
|
headers := make(http.Header)
|
||||||
headers.Set("x-oss-copy-source", source)
|
headers.Set("x-oss-copy-source", source)
|
||||||
|
|
||||||
@ -150,8 +153,9 @@ func (m *Multi) PutPartCopy(n int, options CopyOptions, source string) (*CopyObj
|
|||||||
sourceBucket := m.Bucket.Client.Bucket(strings.TrimRight(strings.Split(source, "/")[1], "/"))
|
sourceBucket := m.Bucket.Client.Bucket(strings.TrimRight(strings.Split(source, "/")[1], "/"))
|
||||||
//log.Println("source: ", source)
|
//log.Println("source: ", source)
|
||||||
//log.Println("sourceBucket: ", sourceBucket.Name)
|
//log.Println("sourceBucket: ", sourceBucket.Name)
|
||||||
//log.Println("HEAD: ", strings.Split(source, "/")[2])
|
//log.Println("HEAD: ", strings.strings.SplitAfterN(source, "/", 3)[2])
|
||||||
sourceMeta, err := sourceBucket.Head(strings.Split(source, "/")[2], nil)
|
// TODO SplitAfterN can be use in bucket name
|
||||||
|
sourceMeta, err := sourceBucket.Head(strings.SplitAfterN(source, "/", 3)[2], nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, Part{}, err
|
return nil, Part{}, err
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ func (d *driver) WriteStream(ctx context.Context, path string, offset int64, rea
|
|||||||
// currentLength >= offset >= chunkSize
|
// currentLength >= offset >= chunkSize
|
||||||
_, part, err = multi.PutPartCopy(partNumber,
|
_, part, err = multi.PutPartCopy(partNumber,
|
||||||
oss.CopyOptions{CopySourceOptions: "bytes=0-" + strconv.FormatInt(offset-1, 10)},
|
oss.CopyOptions{CopySourceOptions: "bytes=0-" + strconv.FormatInt(offset-1, 10)},
|
||||||
d.Bucket.Name+"/"+d.ossPath(path))
|
d.Bucket.Path(d.ossPath(path)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -586,7 +586,7 @@ func (d *driver) WriteStream(ctx context.Context, path string, offset int64, rea
|
|||||||
// offset > currentLength >= chunkSize
|
// offset > currentLength >= chunkSize
|
||||||
_, part, err = multi.PutPartCopy(partNumber,
|
_, part, err = multi.PutPartCopy(partNumber,
|
||||||
oss.CopyOptions{},
|
oss.CopyOptions{},
|
||||||
d.Bucket.Name+"/"+d.ossPath(path))
|
d.Bucket.Path(d.ossPath(path)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user