更新为postgre储存
This commit is contained in:
@@ -21,7 +21,7 @@ func NewFileServiceServer(fileService *service.FileService) *FileServiceServer {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *FileServiceServer) Upload(stream pb.FileService_UploadServer) (*pb.UploadResponse, error) {
|
||||
func (s *FileServiceServer) Upload(stream pb.FileService_UploadServer) error {
|
||||
var fileName, fileType, uploaderType string
|
||||
var uploaderID int32
|
||||
var chunks [][]byte
|
||||
@@ -32,7 +32,7 @@ func (s *FileServiceServer) Upload(stream pb.FileService_UploadServer) (*pb.Uplo
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "receive chunk failed: %v", err)
|
||||
return status.Errorf(codes.Internal, "receive chunk failed: %v", err)
|
||||
}
|
||||
|
||||
if fileName == "" {
|
||||
@@ -53,14 +53,14 @@ func (s *FileServiceServer) Upload(stream pb.FileService_UploadServer) (*pb.Uplo
|
||||
|
||||
file, err := s.fileService.Upload(stream.Context(), fileName, fileType, uploaderType, uploaderID, data)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "upload failed: %v", err)
|
||||
return status.Errorf(codes.Internal, "upload failed: %v", err)
|
||||
}
|
||||
|
||||
return &pb.UploadResponse{
|
||||
return stream.SendAndClose(&pb.UploadResponse{
|
||||
FileId: file.ID,
|
||||
FilePath: file.FilePath,
|
||||
FileUrl: file.FilePath,
|
||||
}, nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *FileServiceServer) GetFile(req *pb.GetFileRequest, stream pb.FileService_GetFileServer) error {
|
||||
|
||||
Reference in New Issue
Block a user