12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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"
- "google.golang.org/grpc"
- "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 {
- conf := zrpc.RpcClientConf{
- Etcd: discov.EtcdConf{
- Key: "moapp.filesystem.rpc",
- Hosts: []string{"192.168.3.206:2379"},
- },
- }
- grpcOpts := []zrpc.ClientOption{
- //zrpc.WithDialOption(grpc.WithWriteBufferSize(40 * 1024 * 1024)), // 设置发送消息的最大字节数,这里是40MB
- //zrpc.WithDialOption(grpc.WithReadBufferSize(40 * 1024 * 1024)), // 设置接收消息的最大字节数,这里也是40MB
- zrpc.WithDialOption(grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(40 * 1024 * 1024))),
- zrpc.WithDialOption(grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(40 * 1024 * 1024))),
- }
- client := zrpc.MustNewClient(conf, grpcOpts...)
- jyFilelLib := filesystemclient.NewFileSystem(client)
- 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: "335a98b93b81dd3a0488a1eecac55d4a.pdf",
- })
- log.Println(resp, "-----", err)
- }
|