forked from TrueCloudLab/rclone
s3: implement link sharing with PublicLink
This commit is contained in:
parent
55ad1354b6
commit
c0521791db
1 changed files with 14 additions and 0 deletions
|
@ -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
|
// Fs returns the parent Fs
|
||||||
|
|
Loading…
Reference in a new issue