Browse Files Media

stable · guide · 0.1.0

上傳與 quarantine

建立 sandbox upload grant

設定 sandbox Project Credential 後執行:

Shell example
: "${MINICENTER_PROJECT_CREDENTIAL:?set the sandbox Project Credential}"
: "${MINICENTER_URL:=https://sandbox.minicenter.otus.tw}"
curl --fail-with-body \
  --request POST \
  --header "Authorization: Bearer ${MINICENTER_PROJECT_CREDENTIAL}" \
  --header "Idempotency-Key: docs-file-upload-1" \
  --header "Content-Type: application/json" \
  --data '{"expected_sha256":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","expected_content_type":"image/png","maximum_bytes":1048576}' \
  "${MINICENTER_URL}/api/v1/file-objects/upload-grants"

回應的 upload token 是短效且 single-use。依 API Reference 把完全相同的 bytes 上傳至 grant URL,再呼叫 completion。File Object 在掃描完成前維持 quarantine,最後只會成為 availablerejected;不要重用 token 或略過 completion。