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] Please make FormData can be hold multiple files with same key #275

Open
husainazkas opened this issue Oct 3, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@husainazkas
Copy link

husainazkas commented Oct 3, 2024

Background

As we all know multipart/form-data generally can holds multiple files with same key. For example:

curl --location 'http://localhost:8088/v1/upload' \
    --form 'files=@"/Users/username/test_0.txt"' \
    --form 'files=@"/Users/username/test_1.txt"' \
    --form 'desc="this is the sample"'

Then can be retrieved

files := request.MultipartForm.File["files"] // This type is []*multipart.FileHeader

Existed

According to the source code in data_source.go line 779, we can see the FormData struct have addFiles function but it only takes the first element of the MultipartForm file arrays. See below:

// AddFiles adds the multipart form files to data
func (d *FormData) AddFiles(filesMap map[string][]*multipart.FileHeader) {
	for key, files := range filesMap {
		if len(files) != 0 {
			d.AddFile(key, files[0])
		}
	}
}

Expected

gookit/validate should hold these multiple files even the form-data key is same so that we can validate it correctly and can get the "safeData" which is a slice of multipart files

@inhere inhere added the enhancement New feature or request label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants