Skip to content

fix: adapt to new Baimiao API v2 with OSS upload#4

Open
zeta987 wants to merge 2 commits intoTechDecryptor:mainfrom
zeta987:fix/api-v2-oss-upload
Open

fix: adapt to new Baimiao API v2 with OSS upload#4
zeta987 wants to merge 2 commits intoTechDecryptor:mainfrom
zeta987:fix/api-v2-oss-upload

Conversation

@zeta987
Copy link
Copy Markdown

@zeta987 zeta987 commented Jan 30, 2026

Fixes #3

Problem

Baimiao web API has changed. The old dataUrl inline upload no longer works:

{
  "code": 0,
  "data": {
    "hash": "8591a..."
  },
  "msg": "图片上传出错,请强制刷新网页后重试"
}
Image

Solution

Adapt to the new API flow: upload image to Aliyun OSS first, then pass fileKey to OCR endpoint.

- Use /api/perm/single with version "v2" parameter
- Fetch OSS signature via /api/oss/sign
- Upload image to Aliyun OSS before calling OCR API
- Pass fileKey instead of dataUrl to OCR endpoint
- Use MD5 hash of image binary instead of SHA1 of dataUrl
- Support multiple image formats (PNG, JPEG, GIF, WebP)

Fixes TechDecryptor#3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
main.js Outdated
username: username,
password: password,
type: /^[0-9]*$/.test(username) ? "mobile" : "email"
type: "email"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you fill in the cell phone number, it will be recognized incorrectly, here you can automatically select the cell phone number and email address according to the presence or absence of "@".

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you fill in the cell phone number, it will be recognized incorrectly, here you can automatically select the cell phone number and email address according to the presence or absence of "@".

Maybe there was a problem. A few minutes ago, I tried to sign in with my email and phone number, but it kept saying “邮箱地址不正确.” After a few minutes, I was able to sign in with my email.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in <3703ed8>.
Login type is now auto-detected:

  • use "email" when username contains "@"
  • otherwise use "mobile"
    Thanks for the suggestion.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you fill in the cell phone number, it will be recognized incorrectly, here you can automatically select the cell phone number and email address according to the presence or absence of "@".

Maybe there was a problem. A few minutes ago, I tried to sign in with my email and phone number, but it kept saying “邮箱地址不正确.” After a few minutes, I was able to sign in with my email.

Based on testing, the login issue can be resolved by clearing the residual plugin data. This can be accomplished using either of the following methods:

Method 1: Reinstall via Application

  1. Completely remove the plugin within the pot app.
  2. Restart the application.
  3. Reinstall the plugin.

Method 2: Manually Delete the Plugin Directory

  1. Close the pot app.
  2. Delete the following directory:
    %APPDATA%\com.pot-app.desktop\plugins\recognize\plugin.com.TechDecryptor.baimiao_ocr
  3. Restart the application and reinstall the plugin.

Performing either step clears the cached configuration and restores normal login functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 白描的圖片上傳邏輯有變,導致 OCR 失效

3 participants