|
@@ -0,0 +1,55 @@
|
|
|
+package test
|
|
|
+
|
|
|
+import (
|
|
|
+ "app.yhyue.com/moapp/jyfs/rpc/filesystem"
|
|
|
+ "app.yhyue.com/moapp/jyfs/rpc/filesystemclient"
|
|
|
+ "fmt"
|
|
|
+ "github.com/gogf/gf/v2/os/gctx"
|
|
|
+ "github.com/zeromicro/go-zero/core/discov"
|
|
|
+ "github.com/zeromicro/go-zero/zrpc"
|
|
|
+ "log"
|
|
|
+ "testing"
|
|
|
+)
|
|
|
+
|
|
|
+var (
|
|
|
+ Domain = "jydocs-std"
|
|
|
+)
|
|
|
+
|
|
|
+func Test_FileUpload(t *testing.T) {
|
|
|
+ log.Println("-------------")
|
|
|
+ //获取附件后上传oss
|
|
|
+ fr := &filesystem.SaveFileReq{
|
|
|
+ Domain: Domain,
|
|
|
+ FileId: fmt.Sprintf("%s.%s", "101010", "doc"),
|
|
|
+ Meta: map[string]string{
|
|
|
+ "docName": "101020",
|
|
|
+ "docSuffix": "doc",
|
|
|
+ "docSize": "24",
|
|
|
+ },
|
|
|
+ RawFileContent: []byte("我是中国人"),
|
|
|
+ }
|
|
|
+ if fr != nil && len(fr.RawFileContent) > 0 {
|
|
|
+ jyFilelLib := filesystemclient.NewFileSystem(zrpc.MustNewClient(zrpc.RpcClientConf{
|
|
|
+ Etcd: discov.EtcdConf{
|
|
|
+ Key: "moapp.filesystem.rpc",
|
|
|
+ Hosts: []string{"192.168.3.206:2379"},
|
|
|
+ },
|
|
|
+ }))
|
|
|
+ fRes, err := jyFilelLib.SaveFile(gctx.New(), fr)
|
|
|
+ log.Println(fRes, "----------", err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func Test_GetFile(t *testing.T) {
|
|
|
+ jyFilelLib := filesystemclient.NewFileSystem(zrpc.MustNewClient(zrpc.RpcClientConf{
|
|
|
+ Etcd: discov.EtcdConf{
|
|
|
+ Key: "moapp.filesystem.rpc",
|
|
|
+ Hosts: []string{"192.168.3.206:2379"},
|
|
|
+ },
|
|
|
+ }))
|
|
|
+ resp, err := jyFilelLib.GetOssUril(gctx.New(), &filesystem.LoadFileReq{
|
|
|
+ Domain: Domain,
|
|
|
+ FileId: "e7808fb6ac51bce32d9131248850a5fb.doc",
|
|
|
+ })
|
|
|
+ log.Println(resp, "-----", err)
|
|
|
+}
|