|
@@ -21,113 +21,113 @@ func init() {
|
|
|
conf.MustLoad("./filesystem.yaml", &C)
|
|
|
}
|
|
|
|
|
|
-// 创建域
|
|
|
-func Test_CreateDomain(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- req := &filesystem.DomainReq{Name: "jy-oss-xzh", MetaFields: []string{"docName", "docSuffix", "docSize"}}
|
|
|
- res, err := FileSystem.CreateDomain(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 创建域
|
|
|
+// func Test_CreateDomain(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// req := &filesystem.DomainReq{Name: "jy-oss-xzh", MetaFields: []string{"docName", "docSuffix", "docSize"}}
|
|
|
+// res, err := FileSystem.CreateDomain(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 删除域
|
|
|
-func Test_DeleteDomain(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- req := &filesystem.DomainReq{Name: "jy-oss-xzh", MetaFields: []string{"docName", "docSuffix", "docSize"}}
|
|
|
- res, err := FileSystem.DeleteDomain(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 删除域
|
|
|
+// func Test_DeleteDomain(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// req := &filesystem.DomainReq{Name: "jy-oss-xzh", MetaFields: []string{"docName", "docSuffix", "docSize"}}
|
|
|
+// res, err := FileSystem.DeleteDomain(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 更新域
|
|
|
-func Test_UpdateDomainMeta(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- req := &filesystem.DomainReq{Name: "jy-oss-xzh", MetaFields: []string{"docName", "docSuffix", "docSize", "docPage"}}
|
|
|
- res, err := FileSystem.UpdateDomainMeta(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 更新域
|
|
|
+// func Test_UpdateDomainMeta(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// req := &filesystem.DomainReq{Name: "jy-oss-xzh", MetaFields: []string{"docName", "docSuffix", "docSize", "docPage"}}
|
|
|
+// res, err := FileSystem.UpdateDomainMeta(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 删除文件
|
|
|
-func Test_DeleteFile(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- req := &filesystem.LoadFileReq{Domain: "jy-oss-xzh", FileId: "que.txt"}
|
|
|
- res, err := FileSystem.DeleteFile(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 删除文件
|
|
|
+// func Test_DeleteFile(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// req := &filesystem.LoadFileReq{Domain: "jy-oss-xzh", FileId: "que.txt"}
|
|
|
+// res, err := FileSystem.DeleteFile(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 获取文件
|
|
|
-func Test_GetFile(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- req := &filesystem.LoadFileReq{Domain: "jy-oss-xzh", FileId: "que.txt"}
|
|
|
- res, err := FileSystem.GetFile(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 获取文件
|
|
|
+// func Test_GetFile(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// req := &filesystem.LoadFileReq{Domain: "jy-oss-xzh", FileId: "que.txt"}
|
|
|
+// res, err := FileSystem.GetFile(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 获取文件元数据
|
|
|
-func Test_GetFileMeta(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- req := &filesystem.LoadFileReq{Domain: "jy-oss-xzh", FileId: "que.txt"}
|
|
|
- res, err := FileSystem.GetFileMeta(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 获取文件元数据
|
|
|
+// func Test_GetFileMeta(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// req := &filesystem.LoadFileReq{Domain: "jy-oss-xzh", FileId: "que.txt"}
|
|
|
+// res, err := FileSystem.GetFileMeta(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 保存文件
|
|
|
-func Test_SaveFile(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- file, err := os.Open("./111.txt")
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- defer file.Close()
|
|
|
- // FileInfo:
|
|
|
- stats, err := file.Stat()
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- // []byte
|
|
|
- data := make([]byte, stats.Size())
|
|
|
- count, err := file.Read(data)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- log.Println(count)
|
|
|
- req := &filesystem.SaveFileReq{
|
|
|
- Domain: "jy-oss-xzh",
|
|
|
- FileId: "111.txt",
|
|
|
- Meta: map[string]string{"docName": "111", "docSuffix": ".txt", "docSize": "1024"},
|
|
|
- RawFileContent: data,
|
|
|
- }
|
|
|
- res, err := FileSystem.SaveFile(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 保存文件
|
|
|
+// func Test_SaveFile(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// file, err := os.Open("./111.txt")
|
|
|
+// if err != nil {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// defer file.Close()
|
|
|
+// // FileInfo:
|
|
|
+// stats, err := file.Stat()
|
|
|
+// if err != nil {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// // []byte
|
|
|
+// data := make([]byte, stats.Size())
|
|
|
+// count, err := file.Read(data)
|
|
|
+// if err != nil {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// log.Println(count)
|
|
|
+// req := &filesystem.SaveFileReq{
|
|
|
+// Domain: "jy-oss-xzh",
|
|
|
+// FileId: "111.txt",
|
|
|
+// Meta: map[string]string{"docName": "111", "docSuffix": ".txt", "docSize": "1024"},
|
|
|
+// RawFileContent: data,
|
|
|
+// }
|
|
|
+// res, err := FileSystem.SaveFile(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 更新文件元数据
|
|
|
-func Test_UpdateFileMeta(t *testing.T) {
|
|
|
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
- req := &filesystem.UpdateFileMetaReq{
|
|
|
- Domain: "jy-oss-xzh",
|
|
|
- FileId: "que.txt",
|
|
|
- Meta: map[string]string{"docName": "que", "docSuffix": ".txt", "docSize": "2048"},
|
|
|
- }
|
|
|
- res, err := FileSystem.UpdateFileMeta(ctx, req)
|
|
|
- log.Println("err ", err)
|
|
|
- log.Println("req ", res)
|
|
|
-}
|
|
|
+// // 更新文件元数据
|
|
|
+// func Test_UpdateFileMeta(t *testing.T) {
|
|
|
+// ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+// FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|
|
|
+// req := &filesystem.UpdateFileMetaReq{
|
|
|
+// Domain: "jy-oss-xzh",
|
|
|
+// FileId: "que.txt",
|
|
|
+// Meta: map[string]string{"docName": "que", "docSuffix": ".txt", "docSize": "2048"},
|
|
|
+// }
|
|
|
+// res, err := FileSystem.UpdateFileMeta(ctx, req)
|
|
|
+// log.Println("err ", err)
|
|
|
+// log.Println("req ", res)
|
|
|
+// }
|
|
|
|
|
|
-// 更新文件元数据
|
|
|
+// 获取ossUrl
|
|
|
func Test_GetOssUrl(t *testing.T) {
|
|
|
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
|