feat: add expiration field for Link

This commit is contained in:
Noah Hsu
2022-06-13 15:39:47 +08:00
parent 3e8f36e9f3
commit e16ab876aa
4 changed files with 37 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package driver
import (
"io"
"net/http"
"time"
)
type LinkArgs struct {
@ -11,9 +12,10 @@ type LinkArgs struct {
}
type Link struct {
URL string
Header http.Header
Data io.ReadCloser
Status int
FilePath string
URL string
Header http.Header // needed header
Data io.ReadCloser // return file reader directly
Status int // status maybe 200 or 206, etc
FilePath string // local file, return the filepath
Expiration *time.Duration // url expiration time
}

View File

@ -52,7 +52,11 @@ func Get(ctx context.Context, account driver.Driver, path string) (driver.FileIn
// Link get link, if is a url. show have an expiry time
func Link(ctx context.Context, account driver.Driver, path string, args driver.LinkArgs) (*driver.Link, error) {
return account.Link(ctx, path, args)
link, err := account.Link(ctx, path, args)
if err != nil {
return nil, errors.WithMessage(err, "failed get link")
}
return link, nil
}
func MakeDir(ctx context.Context, account driver.Driver, path string) error {