Skip to content

Commit eb3e5a4

Browse files
committed
add for oss
Signed-off-by: Ashwanth Goli <[email protected]>
1 parent 9b20509 commit eb3e5a4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

providers/oss/oss.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"testing"
1717
"time"
1818

19+
"github.com/aliyun/aliyun-oss-go-sdk/oss"
1920
alioss "github.com/aliyun/aliyun-oss-go-sdk/oss"
2021
"github.com/go-kit/log"
2122
"github.com/pkg/errors"
@@ -342,12 +343,17 @@ func (b *Bucket) getRange(_ context.Context, name string, off, length int64) (io
342343
opts = append(opts, opt)
343344
}
344345

345-
resp, err := b.bucket.GetObject(name, opts...)
346+
resp, err := b.bucket.DoGetObject(&oss.GetObjectRequest{ObjectKey: name}, opts)
346347
if err != nil {
347348
return nil, err
348349
}
349350

350-
return resp, nil
351+
size, err := clientutil.ParseContentLength(resp.Response.Headers)
352+
if err == nil {
353+
return objstore.ObjectSizerReadCloser{ReadCloser: resp.Response, Size: size}, nil
354+
}
355+
356+
return resp.Response, nil
351357
}
352358

353359
// Get returns a reader for the given object name.

0 commit comments

Comments
 (0)