增加文件相关API

This commit is contained in:
刘祥超
2021-02-25 21:07:48 +08:00
parent ea8a3079a7
commit dfda15ecc9
5 changed files with 50 additions and 10 deletions

View File

@@ -32,11 +32,13 @@ func (this *FileChunkService) CreateFileChunk(ctx context.Context, req *pb.Creat
// 获取的一个文件的所有片段IDs
func (this *FileChunkService) FindAllFileChunkIds(ctx context.Context, req *pb.FindAllFileChunkIdsRequest) (*pb.FindAllFileChunkIdsResponse, error) {
// 校验请求
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeNode, rpcutils.UserTypeAdmin)
_, _, err := this.ValidateAdminAndUser(ctx, 0, -1)
if err != nil {
return nil, err
}
// TODO 校验用户
tx := this.NullTx()
chunkIds, err := models.SharedFileChunkDAO.FindAllFileChunkIds(tx, req.FileId)
@@ -49,11 +51,13 @@ func (this *FileChunkService) FindAllFileChunkIds(ctx context.Context, req *pb.F
// 下载文件片段
func (this *FileChunkService) DownloadFileChunk(ctx context.Context, req *pb.DownloadFileChunkRequest) (*pb.DownloadFileChunkResponse, error) {
// 校验请求
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeNode, rpcutils.UserTypeAdmin)
_, _, err := this.ValidateAdminAndUser(ctx, 0, -1)
if err != nil {
return nil, err
}
// TODO 校验用户
tx := this.NullTx()
chunk, err := models.SharedFileChunkDAO.FindFileChunk(tx, req.FileChunkId)