feat: add expiration field for Link
This commit is contained in:
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user