MCPcopy Index your code
hub / github.com/dearcode/candy / DownloadFile

Method DownloadFile

gate/server.go:474–487  ·  view source on GitHub ↗

DownloadFile 客户端下载文件,传入ID,返回具体文件内容.

(ctx context.Context, req *meta.GateDownloadFileRequest)

Source from the content-addressed store, hash-verified

472
473// DownloadFile 客户端下载文件,传入ID,返回具体文件内容.
474func (g *Gate) DownloadFile(ctx context.Context, req *meta.GateDownloadFileRequest) (*meta.GateDownloadFileResponse, error) {
475 s, err := g.getOnlineSession(ctx)
476 if err != nil {
477 log.Errorf("getSession error:%s", errors.ErrorStack(err))
478 return &meta.GateDownloadFileResponse{Header: &meta.ResponseHeader{Code: util.ErrorGetOnlineSession, Msg: err.Error()}}, nil
479 }
480
481 files, err := g.store.downloadFile(s.id, req.Names)
482 if err != nil {
483 return &meta.GateDownloadFileResponse{Header: &meta.ResponseHeader{Code: util.ErrorDownloadFile, Msg: err.Error()}}, nil
484 }
485
486 return &meta.GateDownloadFileResponse{Files: files}, nil
487}
488
489// LoadMessage 客户端同步离线消息,每次可逆序(旧消息)或正序(新消息)接收100条
490func (g *Gate) LoadMessage(ctx context.Context, req *meta.GateLoadMessageRequest) (*meta.GateLoadMessageResponse, error) {

Callers

nothing calls this directly

Calls 3

getOnlineSessionMethod · 0.95
downloadFileMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected