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

Feature Request: Support Square Bracket Notation in Multipart Form Data #3224

Closed
coderabbitai bot opened this issue Dec 1, 2024 · 0 comments · Fixed by #3235
Closed

Feature Request: Support Square Bracket Notation in Multipart Form Data #3224

coderabbitai bot opened this issue Dec 1, 2024 · 0 comments · Fixed by #3235
Assignees
Milestone

Comments

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2024

Description

Currently, Fiber supports square bracket notation in form data when using 'application/x-www-form-urlencoded' content type, but this feature is not available for multipart form data. This limits the ability to handle complex nested data structures in multipart form requests.

Current Behavior

  • Square bracket notation works with 'application/x-www-form-urlencoded'
  • Multipart form data does not support square bracket notation for nested structures
  • No support for comma-separated values in multipart form data

Desired Behavior

  • Support square bracket notation in multipart form data (e.g., field[0][name], field[1][name])
  • Support comma-separated values in multipart form data fields
  • Maintain the ability to transfer binary data alongside structured form data

Use Case Example

text_prompts[0][text]: "A beautiful sunset over the ocean"
text_prompts[0][weight]: 0.7
text_prompts[1][text]: "mountain range covered in snow"
text_prompts[1][weight]: -0.5
init_image: <binary_data>

References

  • Original Issue: 🤗 [Question]: bodyParser nested with bracket notation #3223
  • Current Implementation (form-urlencoded):

    fiber/ctx.go

    Lines 394 to 408 in 8c84b0f

    if strings.HasPrefix(ctype, MIMEApplicationForm) {
    data := make(map[string][]string)
    var err error
    c.fasthttp.PostArgs().VisitAll(func(key, val []byte) {
    if err != nil {
    return
    }
    k := c.app.getString(key)
    v := c.app.getString(val)
    if strings.Contains(k, "[") {
    k, err = parseParamSquareBrackets(k)
    }
  • Current Implementation (multipart):

    fiber/ctx.go

    Lines 422 to 427 in 8c84b0f

    if strings.HasPrefix(ctype, MIMEMultipartForm) {
    data, err := c.fasthttp.MultipartForm()
    if err != nil {
    return err
    }
    return c.parseToStruct(bodyTag, out, data.Value)

Additional Notes

This enhancement would provide consistency between form-urlencoded and multipart form data handling, making it easier for developers to work with complex data structures while maintaining the ability to upload files.

@ReneWerner87 ReneWerner87 added this to v3 Dec 1, 2024
@ReneWerner87 ReneWerner87 added this to the v3 milestone Dec 1, 2024
@efectn efectn moved this to Todo in v3 Dec 5, 2024
@efectn efectn self-assigned this Dec 5, 2024
@efectn efectn moved this from Todo to In Progress in v3 Dec 6, 2024
@ReneWerner87 ReneWerner87 modified the milestones: v3, Next Release Dec 31, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in v3 Dec 31, 2024
ReneWerner87 added a commit that referenced this issue Dec 31, 2024
* Feature Request: Support Square Bracket Notation in Multipart Form Data #3224

* Feature Request: Support Square Bracket Notation in Multipart Form Data #3224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants