yikart/AiToEarn · error · Error

上传封面失败,失败原因:获取上传id失败

Error message

上传封面失败,失败原因:获取上传id失败

What it means

Mirror of error 364 but for the cover/thumbnail image: uploadCoverFile requests an initial UploadID from the COS endpoint and throws if none is returned. The cover upload never started because the upload session could not be created.

Source

Thrown at project/aitoearn-electron/electron/plat/shipinhao/index.ts:825

      const uploadIdRes = await this.uploadFile(
        this.getApplyUploadDfsUrl,
        Buffer.from(
          JSON.stringify({
            BlockPartLength: [fileData.length],
            BlockSum: 1,
          }),
        ),
        {
          Authorization: uploadParams.authKey,
          'Content-Type': 'application/json',
          'X-Arguments': uploadArgumentsString,
        },
        undefined,
        proxy,
      );

      if (!uploadIdRes.UploadID) {
        throw new Error('上传封面失败,失败原因:获取上传id失败');
      }

      const uploadId = uploadIdRes.UploadID;

      // 开始上传
      const uploadPartRes = await this.uploadFile(
        this.uploadpartdfsUrl +
          `?UploadID=${uploadId}&PartNumber=1&QuickUpload=2`,
        fileData,
        {
          Authorization: uploadParams.authKey,
          'X-Arguments': uploadArgumentsString,
          'Content-Type': 'application/octet-stream',
        },
        undefined,
        proxy,
      );

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Verify the cover image exists locally and is a valid image with expected size.
  2. Re-obtain upload params (fresh traceKey) before retrying the cover upload.
  3. Log the full uploadIdRes response to read the COS error code.
  4. Retry after backoff if the server was throttling.

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'fs';
if (!fs.existsSync(coverPath)) throw new Error('cover file missing');
if (fs.statSync(coverPath).size === 0) throw new Error('cover file empty');

Type guard

function hasUploadId(res: unknown): res is { UploadID: string } {
  return typeof (res as any)?.UploadID === 'string' && (res as any).UploadID.length > 0;
}

Try / catch

try {
  await service.uploadCoverFile(/*...*/);
} catch (e) {
  if (e.message.includes('获取上传id失败')) {
    // refetch upload params, verify cover file, retry
  }
}

Prevention

When it happens

Trigger: uploadCoverFile → apply-upload response lacks UploadID: invalid upload params, missing/oversized cover file, COS rejecting the request due to bad signature or throttling.

Common situations: Cover file path wrong or file unreadable (0 bytes sent), stale upload params, Shipinhao session expiry, or COS rate limiting.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/568c5afa82463646. Report an issue: GitHub.