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

support http multipart request #4378

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

dakunge
Copy link

@dakunge dakunge commented Sep 18, 2024

go-zero doesn't support uploading files well, need to modifies handler and logic files manually, eg: https://github.com/zeromicro/zero-examples/blob/main/http/upload/internal/logic/uploadlogic.go#L33

I found it's easy to support uploading files graceful and there will be no impact on existing functions and code

  1. support file tag in api
  2. a little change in genFile function
  3. a little change in handler.tpl and logic.tpl

test api file:
`
syntax = "v1"

type (
UploadRequest {
File1 string file:"file1"
File2 string file:"file2"
Other string json:"string"
}
UploadResponse {}
)

service Test {
@handler Upload
post /upload (UploadRequest) returns (UploadResponse)
}

`

I think multipart request is standard http , we should support it.

@dakunge dakunge marked this pull request as draft December 29, 2024 15:44
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