MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / UploadPrivateFile

Method UploadPrivateFile

client/richmedia.go:487–555  ·  view source on GitHub ↗
(targetUID string, file *message.FileElement)

Source from the content-addressed store, hash-verified

485}
486
487func (c *QQClient) UploadPrivateFile(targetUID string, file *message.FileElement) (*message.FileElement, error) {
488 if file == nil || file.FileStream == nil {
489 return nil, errors.New("element type is not file")
490 }
491 req, err := oidb.BuildPrivateFileUploadReq(c.GetUID(c.Uin), targetUID, file)
492 if err != nil {
493 return nil, err
494 }
495 resp, err := c.sendOidbPacketAndWait(req)
496 if err != nil {
497 return nil, err
498 }
499 uploadResp, err := oidb.ParsePrivateFileUploadResp(resp)
500 if err != nil {
501 return nil, err
502 }
503 if !uploadResp.Upload.BoolFileExist {
504 ext := &highway.FileUploadExt{
505 Unknown1: 100,
506 Unknown2: 1,
507 Entry: &highway.FileUploadEntry{
508 BusiBuff: &highway.ExcitingBusiInfo{
509 SenderUin: uint64(c.Uin),
510 },
511 FileEntry: &highway.ExcitingFileEntry{
512 FileSize: file.FileSize,
513 Md5: file.FileMd5,
514 CheckKey: file.FileSha1,
515 Md5S2: file.FileMd5,
516 FileId: uploadResp.Upload.Uuid,
517 UploadKey: uploadResp.Upload.MediaPlatformUploadKey,
518 },
519 ClientInfo: &highway.ExcitingClientInfo{
520 ClientType: 3,
521 AppId: "100",
522 TerminalType: 3,
523 ClientVer: "1.1.1",
524 Unknown: 4,
525 },
526 FileNameInfo: &highway.ExcitingFileNameInfo{
527 FileName: file.FileName,
528 },
529 Host: &highway.ExcitingHostConfig{
530 Hosts: []*highway.ExcitingHostInfo{
531 {
532 Url: &highway.ExcitingUrlInfo{
533 Unknown: 1,
534 Host: uploadResp.Upload.UploadIp,
535 },
536 Port: uploadResp.Upload.UploadPort,
537 },
538 },
539 },
540 },
541 Unknown200: 1,
542 Unknown3: 0,
543 }
544 extStream, err := proto.Marshal(ext)

Callers 1

SendPrivateFileMethod · 0.95

Calls 4

GetUIDMethod · 0.95
sendOidbPacketAndWaitMethod · 0.95
highwayUploadMethod · 0.95
MarshalFunction · 0.92

Tested by

no test coverage detected