validate icon indicating copy to clipboard operation
validate copied to clipboard

[FEATURE REQUEST] Please make FormData can be hold multiple files with same key

Open husainazkas opened this issue 4 months ago • 0 comments

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

husainazkas avatar Oct 03 '24 15:10 husainazkas