Skip to content

fix(upload): send browser content type for direct uploads - #692

Open
mumingluan wants to merge 1 commit into
OpenListTeam:mainfrom
mumingluan:codex/direct-upload-content-type
Open

mumingluan wants to merge 1 commit into
OpenListTeam:mainfrom
mumingluan:codex/direct-upload-content-type

Conversation

@mumingluan

Copy link
Copy Markdown

Summary / 摘要

Send the browser's File.type in the optional content_type field when requesting a direct-upload URL. Use application/octet-stream when the browser provides no type.

This lets the companion backend change sign the client-selected Content-Type and return the matching upload header, fixing Ceph RGW uploads that reject an unsigned media type. The upload code already applies the headers returned by the backend.

  • This PR has breaking changes.
  • This PR changes public API, config, storage format, or migration behavior.
    Adds the optional content_type field to the direct-upload information request.
  • This PR requires corresponding changes in related repositories.

Related repository PRs / 关联仓库 PR:

Testing / 测试

  • Prettier check for src/pages/home/uploads/direct.ts and git diff --check passed.
  • Executed the changed upload function in an isolated Node File/XHR harness. A .apk with text/plain and a file with an empty type send the expected request field and matching upload header.
  • With the companion backend driver, Rainyun/Ceph and Cloudflare R2 uploads succeeded when the supplied MIME type differed from the extension. An 80 MiB Rainyun upload using the empty-type fallback also succeeded. Object sizes were verified and temporary objects were deleted.
  • pnpm run lint reports seven errors in unrelated files. TypeScript checking at the original frontend HEAD produced identical diagnostics.

Checklist / 检查清单

  • I have read the linked OpenList contribution instructions and the PR template.
  • The contribution follows the repository license and contribution format.
  • The changed code is formatted with Prettier.
  • The human collaborator reviewed the proposed change and approved submission.

AI Disclosure / AI 使用声明

  • This PR includes AI-assisted content.
  • Tools used: Codex.
  • Usage scope: implementation, validation, and PR wording.
  • Codex performed the checks described above. The human collaborator requested the change in response to maintainer feedback, reviewed it, and approved submission.
  • AI-assisted commits include the required Co-authored-by attribution.

- Supply File.type when requesting a direct upload URL
- Use application/octet-stream when the browser has no MIME type

Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
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.

1 participant