(param *uploadSessionParam)
| 228 | } |
| 229 | |
| 230 | func (c *QQClient) getGroupAlbumUploadSession(param *uploadSessionParam) (*uploadOptions, int64, error) { |
| 231 | reqBody, timeStamp, err := c.buildUploadSessionReq(param) |
| 232 | if err != nil { |
| 233 | return nil, timeStamp, err |
| 234 | } |
| 235 | reqBodyData, err := json.Marshal(reqBody) |
| 236 | if err != nil { |
| 237 | return nil, timeStamp, err |
| 238 | } |
| 239 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| 240 | defer cancel() |
| 241 | req, err := http.NewRequestWithContext(ctx, http.MethodPost, |
| 242 | fmt.Sprintf("https://h5.qzone.qq.com/webapp/json/sliceUpload/FileBatchControl/%x?g_tk=%d", param.CheckSum, param.GTK), |
| 243 | bytes.NewReader(reqBodyData)) |
| 244 | if err != nil { |
| 245 | return nil, timeStamp, err |
| 246 | } |
| 247 | req.Header.Set("Content-Type", "application/json") |
| 248 | resp, err := c.SendRequestWithCookie(req) |
| 249 | if err != nil { |
| 250 | return nil, timeStamp, err |
| 251 | } |
| 252 | respData, err := io.ReadAll(resp.Body) |
| 253 | _ = resp.Body.Close() |
| 254 | if err != nil { |
| 255 | return nil, timeStamp, err |
| 256 | } |
| 257 | respJSON := gjson.ParseBytes(respData) |
| 258 | if respJSON.Get("ret").Int() != 0 { |
| 259 | return nil, timeStamp, fmt.Errorf("error: ret:%d, msg:%s", respJSON.Get("ret").Int(), respJSON.Get("msg").Str) |
| 260 | } |
| 261 | return &uploadOptions{ |
| 262 | Session: respJSON.Get("data.session").Str, |
| 263 | BlockSize: int(respJSON.Get("data.slice_size").Int()), |
| 264 | }, timeStamp, nil |
| 265 | } |
| 266 | |
| 267 | func (c *QQClient) uploadGroupAlbumBlock(typ uploadTypeParam, session string, seq, offset, chunkSize, totalSize, gtk int, chunk []byte, latest bool) (rsp *uploadBlockRsp, err error) { |
| 268 | uploadURLCmd := utils.Ternary[string](typ.ResourceType == ResourceTypeVideo, "FileUploadVideo", "FileUpload") |
no test coverage detected