51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
// Code generated by goctl. DO NOT EDIT.
|
|
// goctl 1.9.2
|
|
// Source: objectstory.proto
|
|
|
|
package fileservice
|
|
|
|
import (
|
|
"context"
|
|
|
|
"juwan-backend/app/objectstory/rpc/pb"
|
|
|
|
"github.com/zeromicro/go-zero/zrpc"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type (
|
|
GetFileUrlReq = pb.GetFileUrlReq
|
|
GetFileUrlResp = pb.GetFileUrlResp
|
|
UploadFileMetadataReq = pb.UploadFileMetadataReq
|
|
UploadFileResp = pb.UploadFileResp
|
|
|
|
FileService interface {
|
|
// 简单上传(适合小文件,或保存元数据)
|
|
Upload(ctx context.Context, in *UploadFileMetadataReq, opts ...grpc.CallOption) (*UploadFileResp, error)
|
|
// 获取文件访问链接(处理私有文件的鉴权)
|
|
GetFileUrl(ctx context.Context, in *GetFileUrlReq, opts ...grpc.CallOption) (*GetFileUrlResp, error)
|
|
}
|
|
|
|
defaultFileService struct {
|
|
cli zrpc.Client
|
|
}
|
|
)
|
|
|
|
func NewFileService(cli zrpc.Client) FileService {
|
|
return &defaultFileService{
|
|
cli: cli,
|
|
}
|
|
}
|
|
|
|
// 简单上传(适合小文件,或保存元数据)
|
|
func (m *defaultFileService) Upload(ctx context.Context, in *UploadFileMetadataReq, opts ...grpc.CallOption) (*UploadFileResp, error) {
|
|
client := pb.NewFileServiceClient(m.cli.Conn())
|
|
return client.Upload(ctx, in, opts...)
|
|
}
|
|
|
|
// 获取文件访问链接(处理私有文件的鉴权)
|
|
func (m *defaultFileService) GetFileUrl(ctx context.Context, in *GetFileUrlReq, opts ...grpc.CallOption) (*GetFileUrlResp, error) {
|
|
client := pb.NewFileServiceClient(m.cli.Conn())
|
|
return client.GetFileUrl(ctx, in, opts...)
|
|
}
|