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.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package cmdline
  2. import (
  3. "fmt"
  4. "github.com/jedib0t/go-pretty/v6/table"
  5. "gitlink.org.cn/cloudream/client/internal/services"
  6. )
  7. func (c *Commandline) ListUserBuckets() error {
  8. userID := 0
  9. buckets, err := services.BucketSvc(c.svc).GetUserBuckets(userID)
  10. if err != nil {
  11. return err
  12. }
  13. fmt.Printf("Find %d buckets for user %d:\n", len(buckets), userID)
  14. tb := table.NewWriter()
  15. tb.AppendHeader(table.Row{"ID", "Name", "CreatorID"})
  16. for _, bucket := range buckets {
  17. tb.AppendRow(table.Row{bucket.BucketID, bucket.Name, bucket.CreatorID})
  18. }
  19. fmt.Print(tb.Render())
  20. return nil
  21. }
  22. func (c *Commandline) CreateBucket(bucketName string) error {
  23. userID := 0
  24. bucketID, err := services.BucketSvc(c.svc).CreateBucket(userID, bucketName)
  25. if err != nil {
  26. return err
  27. }
  28. fmt.Printf("Create bucket %s success, id: %d", bucketName, bucketID)
  29. return nil
  30. }
  31. func (c *Commandline) DeleteBucket(bucketID int) error {
  32. userID := 0
  33. err := services.BucketSvc(c.svc).DeleteBucket(userID, bucketID)
  34. if err != nil {
  35. return err
  36. }
  37. fmt.Printf("Delete bucket %d success ", bucketID)
  38. return nil
  39. }

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