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.

presigned_test.go 3.7 kB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package api
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "gitlink.org.cn/cloudream/common/pkgs/types"
  6. "gitlink.org.cn/cloudream/jcs-pub/client/sdk/api"
  7. )
  8. func Test_Presigned(t *testing.T) {
  9. cli := NewClient(api.Config{
  10. EndPoint: "http://localhost:7890",
  11. })
  12. Convey("下载文件", t, func() {
  13. pre := cli.Presigned()
  14. url, err := pre.ObjectDownloadByPath(PresignedObjectDownloadByPath{
  15. PackageID: 3,
  16. Path: "example.java",
  17. Offset: 1,
  18. Length: types.Ref(int64(100)),
  19. }, 100)
  20. So(err, ShouldEqual, nil)
  21. t.Logf("url: %s", url)
  22. })
  23. Convey("上传文件", t, func() {
  24. pre := cli.Presigned()
  25. url, err := pre.ObjectUpload(PresignedObjectUpload{
  26. PackageID: 3,
  27. Path: "example.java",
  28. }, 100)
  29. So(err, ShouldEqual, nil)
  30. t.Logf("url: %s", url)
  31. })
  32. }
  33. func Test_PresignedObjectListByPath(t *testing.T) {
  34. cli := NewClient(api.Config{
  35. EndPoint: "http://localhost:7890",
  36. })
  37. Convey("下载文件", t, func() {
  38. pre := cli.Presigned()
  39. url, err := pre.ObjectListByPath(PresignedObjectListByPath{
  40. ObjectListByPath: ObjectListByPath{
  41. PackageID: 12,
  42. Path: "a/",
  43. IsPrefix: true,
  44. NoRecursive: true,
  45. MaxKeys: 10,
  46. ContinuationToken: "123456",
  47. },
  48. }, 100)
  49. So(err, ShouldEqual, nil)
  50. t.Logf("url: %s", url)
  51. })
  52. }
  53. func Test_PresignedObjectDownloadByPath(t *testing.T) {
  54. cli := NewClient(api.Config{
  55. EndPoint: "http://localhost:7890",
  56. })
  57. Convey("下载文件", t, func() {
  58. pre := cli.Presigned()
  59. url, err := pre.ObjectDownloadByPath(PresignedObjectDownloadByPath{
  60. PackageID: 3,
  61. Path: "example.java",
  62. // Offset: 1,
  63. // Length: types.Ref(int64(100)),
  64. }, 100)
  65. So(err, ShouldEqual, nil)
  66. t.Logf("url: %s", url)
  67. })
  68. }
  69. func Test_PresignedObjectDownload(t *testing.T) {
  70. cli := NewClient(api.Config{
  71. EndPoint: "http://localhost:7890",
  72. })
  73. Convey("下载文件", t, func() {
  74. pre := cli.Presigned()
  75. url, err := pre.ObjectDownload(PresignedObjectDownload{
  76. ObjectID: 1039,
  77. // Offset: 1,
  78. // Length: types.Ref(int64(100)),
  79. }, 100)
  80. So(err, ShouldEqual, nil)
  81. t.Logf("url: %s", url)
  82. })
  83. }
  84. func Test_PresignedObjectUpload(t *testing.T) {
  85. cli := NewClient(api.Config{
  86. EndPoint: "http://localhost:7890",
  87. })
  88. Convey("上传文件", t, func() {
  89. pre := cli.Presigned()
  90. url, err := pre.ObjectUpload(PresignedObjectUpload{
  91. PackageID: 3,
  92. Path: "example.java",
  93. }, 100)
  94. So(err, ShouldEqual, nil)
  95. t.Logf("url: %s", url)
  96. })
  97. }
  98. func Test_PresignedNewMultipartUpload(t *testing.T) {
  99. cli := NewClient(api.Config{
  100. EndPoint: "http://localhost:7890",
  101. })
  102. Convey("启动分片上传", t, func() {
  103. pre := cli.Presigned()
  104. url, err := pre.ObjectNewMultipartUpload(PresignedObjectNewMultipartUpload{
  105. PackageID: 3,
  106. Path: "example.java",
  107. }, 600)
  108. So(err, ShouldEqual, nil)
  109. t.Logf("url: %s", url)
  110. })
  111. }
  112. func Test_PresignedObjectUploadPart(t *testing.T) {
  113. cli := NewClient(api.Config{
  114. EndPoint: "http://localhost:7890",
  115. })
  116. Convey("上传分片", t, func() {
  117. pre := cli.Presigned()
  118. url, err := pre.ObjectUploadPart(PresignedObjectUploadPart{
  119. ObjectID: 7,
  120. Index: 3,
  121. }, 600)
  122. So(err, ShouldEqual, nil)
  123. t.Logf("url: %s", url)
  124. })
  125. }
  126. func Test_PresignedCompleteMultipartUpload(t *testing.T) {
  127. cli := NewClient(api.Config{
  128. EndPoint: "http://localhost:7890",
  129. })
  130. Convey("合并分片", t, func() {
  131. pre := cli.Presigned()
  132. url, err := pre.ObjectCompleteMultipartUpload(PresignedObjectCompleteMultipartUpload{
  133. ObjectID: 7,
  134. Indexes: []int{1, 2, 3},
  135. }, 600)
  136. So(err, ShouldEqual, nil)
  137. t.Logf("url: %s", url)
  138. })
  139. }

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