You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

bucket.go 1.3 kB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package cmdline
  2. /*
  3. import (
  4. "fmt"
  5. "time"
  6. "github.com/jedib0t/go-pretty/v6/table"
  7. cdssdk "gitlink.org.cn/cloudream/jcs-pub/client/types"
  8. )
  9. func BucketListUserBuckets(ctx CommandContext) error {
  10. buckets, err := ctx.Cmdline.Svc.BucketSvc().GetUserBuckets()
  11. if err != nil {
  12. return err
  13. }
  14. fmt.Printf("Find %d buckets for user %d:\n", len(buckets))
  15. tb := table.NewWriter()
  16. tb.AppendHeader(table.Row{"ID", "Name"})
  17. for _, bucket := range buckets {
  18. tb.AppendRow(table.Row{bucket.BucketID, bucket.Name})
  19. }
  20. fmt.Print(tb.Render())
  21. return nil
  22. }
  23. func BucketCreateBucket(ctx CommandContext, bucketName string) error {
  24. bucketID, err := ctx.Cmdline.Svc.BucketSvc().CreateBucket(bucketName, time.Now())
  25. if err != nil {
  26. return err
  27. }
  28. fmt.Printf("Create bucket %v success, id: %v", bucketName, bucketID)
  29. return nil
  30. }
  31. func BucketDeleteBucket(ctx CommandContext, bucketID cdssdk.BucketID) error {
  32. err := ctx.Cmdline.Svc.BucketSvc().DeleteBucket(bucketID)
  33. if err != nil {
  34. return err
  35. }
  36. fmt.Printf("Delete bucket %d success ", bucketID)
  37. return nil
  38. }
  39. func init() {
  40. commands.MustAdd(BucketListUserBuckets, "bucket", "ls")
  41. commands.MustAdd(BucketCreateBucket, "bucket", "new")
  42. commands.MustAdd(BucketDeleteBucket, "bucket", "delete")
  43. }
  44. */

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。