Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Upload): requestData support array #2078

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

GATING
Copy link

@GATING GATING commented Mar 5, 2025

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

[Upload] 文件数组上传不支持#4188

💡 需求背景和解决方案

修改前:

image

当多个文件一个请求上传,file这个参数被转成了字符串[object File],[object File],这个是无意义的。
且后端也可能会接收数组形式的参数。

修改后:

image

📝 更新日志

  • feat(Upload): 请求参数支持数组

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@tdesign-bot
Copy link
Collaborator

TDesign Component Repositories CI Test Open

Component Lint Test Build
tdesign-vue
tdesign-vue-next
tdesign-react
tdesign-web-components
tdesign-mobile-vue
tdesign-mobile-react

@HaixingOoO HaixingOoO requested a review from Copilot March 6, 2025 09:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR adds support for sending array parameters in the Upload request by modifying the FormData construction logic.

  • Introduces a check for array values in requestData to append each element individually
  • Maintains backward compatibility by appending non-array values as before

Reviewed Changes

File Description
js/upload/xhr.ts Enhances FormData handling to support array values in requestData

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

js/upload/xhr.ts:84

  • [nitpick] Appending array elements using the same key may not be properly recognized by all backends. Consider appending array fields with a modified key (e.g. 'key[]') or verifying that the backend correctly handles multiple entries for the same key.
if (Array.isArray(dataValue)) {

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.

2 participants