Allow restricting file download

This commit is contained in:
2021-12-06 20:13:04 +01:00
parent 570531ce0b
commit 02425ca40c
6 changed files with 333 additions and 155 deletions

View File

@@ -23,6 +23,7 @@ import (
"golang.org/x/term"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/protobuf/types/known/timestamppb"
)
func ActionClientGet(c *cli.Context) error {
@@ -97,6 +98,13 @@ func ActionClientUpload(c *cli.Context) error {
}
req := &pb.UploadFileRequest{Data: data, OriginalFilename: filepath.Base(arg)}
req.WithPasscode = c.Bool("with-passcode")
req.MaxViews = c.Int64("max-views")
if c.IsSet("ttl") {
duration := c.Duration("ttl")
expiresOn := time.Now().Add(duration)
req.ExpiresOn = timestamppb.New(expiresOn)
}
resp, err := client.UploadFile(c.Context, req)
if err != nil {