From e4d5addb0da289fd948a7f3f98d0689f47ba9b06 Mon Sep 17 00:00:00 2001 From: JT Olio Date: Fri, 6 Mar 2020 16:31:06 -0700 Subject: [PATCH] cmd/uplink: add url-based link sharing Change-Id: I83174b2d686be5e5a6910a343b507ab6157aa1f5 --- cmd/uplink/cmd/share.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/uplink/cmd/share.go b/cmd/uplink/cmd/share.go index e2b656f6d..393789f49 100644 --- a/cmd/uplink/cmd/share.go +++ b/cmd/uplink/cmd/share.go @@ -30,6 +30,7 @@ var shareCfg struct { NotAfter string `help:"disallow access after this time (e.g. '+2h', '2020-01-02T15:01:01-01:00')" basic-help:"true"` AllowedPathPrefix []string `help:"whitelist of path prefixes to require, overrides the [allowed-path-prefix] arguments"` ExportTo string `default:"" help:"path to export the shared access to" basic-help:"true"` + BaseURL string `default:"https://link.tardigradeshare.io" help:"the base url for link sharing"` // Share requires information about the current access AccessConfig @@ -142,6 +143,18 @@ func shareMain(cmd *cobra.Command, args []string) (err error) { fmt.Println("=========== SERIALIZED ACCESS WITH THE ABOVE RESTRICTIONS TO SHARE WITH OTHERS ===========") fmt.Println("Access :", newAccessData) + if len(shareCfg.AllowedPathPrefix) == 1 { + fmt.Println("=========== BROWSER URL ==================================================================") + p, err := fpath.New(shareCfg.AllowedPathPrefix[0]) + if err != nil { + return err + } + fmt.Println("URL :", fmt.Sprintf("%s/%s/%s/%s", shareCfg.BaseURL, newAccessData, p.Bucket(), p.Path())) + } else { + fmt.Println("=========== BROWSER URL PREFIX ===========================================================") + fmt.Println("URL :", fmt.Sprintf("%s/%s", shareCfg.BaseURL, newAccessData)) + } + if shareCfg.ExportTo != "" { // convert to an absolute path, mostly for output purposes. exportTo, err := filepath.Abs(shareCfg.ExportTo)