Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "download", Short: "Download an object to a local file", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() did := strings.TrimSpace(downloadDID) if did == "" { return fmt.Errorf("--did is required") } serverURL, err := cmd.Flags().GetString("server") if err != nil { return fmt.Errorf("get server flag: %w", err) } c, err := syclient.New(serverURL) if err != nil { return err } outPath := strings.TrimSpace(downloadOut) if outPath == "" { rec, err := c.Index().Get(ctx, did) if err != nil { return fmt.Errorf("resolve output filename from record: %w", err) } name := did if rec.FileName != nil { name = strings.TrimSpace(*rec.FileName) } outPath = name } if err := os.MkdirAll(filepath.Dir(outPath), 0o755); err != nil { return fmt.Errorf("create output directory: %w", err) } signed, err := c.Data().DownloadURL(ctx, did, 0, false) if err != nil { return fmt.Errorf("get download url: %w", err) } downloadURL := "" if signed.Url != nil { downloadURL = strings.TrimSpace(*signed.Url) } if downloadURL == "" { return fmt.Errorf("empty download url for did %s", did) } if err := downloadURLToPath(ctx, downloadURL, outPath, c); err != nil { return err } fmt.Fprintf(cmd.OutOrStdout(), "downloaded %s -> %s\n", did, outPath) return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.