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

Curl error generated by sending multiple files #1862

Open
cloakscn opened this issue Aug 7, 2024 · 0 comments
Open

Curl error generated by sending multiple files #1862

cloakscn opened this issue Aug 7, 2024 · 0 comments

Comments

@cloakscn
Copy link

cloakscn commented Aug 7, 2024

Describe the bug
Curl error generated by sending multiple files

To Reproduce
Steps to reproduce the behavior:

  1. Write api configuration
// UploadConfigFileAPI
//
//	@Summary	上传配置文件
//	@Tags		config
//	@Accept		multipart/form-data
//	@Produce	json
//	@Param		file	formData	[]file	true	"上传的文件" collectionFormat(multi)
//	@Param		path	formData	string	true	"上传文件要存储的位置"
//	@Success	200		{object}	handler.Result{}
//	@Router		/config/file [post]
func UploadConfigFileAPI(ctx iris.Context) {
	handler.WrapperResult(ctx, func() (interface{}, error) {
		formPath := ctx.FormValue("path")
		files, headers, err := ctx.FormFiles("files", func(ctx iris.Context, header *multipart.FileHeader) bool {
			return true
		})
		if err != nil {
			return nil, errors.WithStack(err)
		}

		software := services.NewSoftware()
		return software.UploadFiles(formPath, files, headers)
	})
}
  1. Generate api documentation
swag fmt && swag init
  1. Send form data request
    4541622582
  2. Check the wrong curl command
curl -X POST "http://localhost:8080/openapi/v1/config/file" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "files={},{}" -F "path=a"

Expected behavior

curl -X POST "http://localhost:8080/openapi/v1/config/file" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "files=@file1.txt" -F "files=@file2.txt" -F "path=a"

Screenshots
4541622582

Your swag version
e.g. 1.16.3

Your go version
e.g. 1.22

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser: chrome
  • Version: 127.0.6533.88 (Official Build) (64-bit)

Additional context
Add any other context about the problem here.

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

No branches or pull requests

1 participant