s3: implement link sharing with PublicLink

This commit is contained in:
Roman Kredentser 2020-06-05 00:03:12 +03:00 committed by Nick Craig-Wood
parent 55ad1354b6
commit c0521791db
1 changed files with 14 additions and 0 deletions

View File

@ -1959,6 +1959,20 @@ func (f *Fs) getMemoryPool(size int64) *pool.Pool {
)
}
// PublicLink generates a public link to the remote path (usually readable by anyone)
func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration, unlink bool) (link string, err error) {
if _, err := f.NewObject(ctx, remote); err != nil {
return "", err
}
bucket, bucketPath := f.split(remote)
httpReq, _ := f.c.GetObjectRequest(&s3.GetObjectInput{
Bucket: &bucket,
Key: &bucketPath,
})
return httpReq.Presign(time.Duration(expire))
}
// ------------------------------------------------------------
// Fs returns the parent Fs