Returning functional snapshot download link
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adam Štrauch 2021-11-03 23:50:58 +01:00
parent 872826c0b1
commit 3120a8c6ee
Signed by: cx
GPG key ID: 018304FFA8988F8D
2 changed files with 13 additions and 1 deletions

View file

@ -172,5 +172,8 @@ func (s S3Driver) GetDownloadLink(key string) (string, error) {
return "", fmt.Errorf("generating presign URL error: %v", err)
}
return presignedURL.String(), nil
if s.S3SSL {
return fmt.Sprintf("https://%s%s?%s", s.S3Endpoint, presignedURL.Path, presignedURL.RawQuery), nil
}
return fmt.Sprintf("http://%s%s?%s", s.S3Endpoint, presignedURL.Path, presignedURL.RawQuery), nil
}

View file

@ -77,3 +77,12 @@ func TestS3Delete(t *testing.T) {
assert.Nil(t, err)
assert.NotContains(t, keys, "testkey")
}
func TestGetDownloadLink(t *testing.T) {
err := testS3Driver.Write("testkey", []byte(testContent))
assert.Nil(t, err)
link, err := testS3Driver.GetDownloadLink("testkey")
assert.Nil(t, err)
assert.Contains(t, link, "/testsnapshots/testkey?X-Amz-Algorithm=AWS4-HMAC-SHA256")
}