Fixes downloads in Minio Browser (#264)

This commit is contained in:
Kaloyan Raev 2018-08-22 14:15:13 +03:00 committed by littleskunk
parent fe3decc42f
commit 62521bb3f8
2 changed files with 5 additions and 1 deletions

View File

@ -113,6 +113,9 @@ func (s *storjObjects) GetObject(ctx context.Context, bucket, object string,
return err return err
} }
defer utils.LogClose(rr) defer utils.LogClose(rr)
if length == -1 {
length = rr.Size() - startOffset
}
r, err := rr.Range(ctx, startOffset, length) r, err := rr.Range(ctx, startOffset, length)
if err != nil { if err != nil {
return err return err

View File

@ -57,7 +57,8 @@ func TestGetObject(t *testing.T) {
{"mybucket", "myobject1", "abcdef", 0, 5, "abcde", nil, ""}, {"mybucket", "myobject1", "abcdef", 0, 5, "abcde", nil, ""},
// error returned by the ranger in the code // error returned by the ranger in the code
{"mybucket", "myobject1", "abcdef", -1, 7, "abcde", nil, "ranger error: negative offset"}, {"mybucket", "myobject1", "abcdef", -1, 7, "abcde", nil, "ranger error: negative offset"},
{"mybucket", "myobject1", "abcdef", 0, -1, "abcde", nil, "ranger error: negative length"}, {"mybucket", "myobject1", "abcdef", 0, -1, "abcdef", nil, ""},
{"mybucket", "myobject1", "abcdef", 0, -2, "abcde", nil, "ranger error: negative length"},
{"mybucket", "myobject1", "abcdef", 1, 7, "bcde", nil, "ranger error: buffer runoff"}, {"mybucket", "myobject1", "abcdef", 1, 7, "bcde", nil, "ranger error: buffer runoff"},
// error returned by the objects.Get() // error returned by the objects.Get()
{"mybucket", "myobject1", "abcdef", 0, 6, "abcdef", errors.New("some err"), "some err"}, {"mybucket", "myobject1", "abcdef", 0, 6, "abcdef", errors.New("some err"), "some err"},