mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
POST Policy, multiple fixes: AccessDenied with unmet conditions, ${filename} in Key, missing filename in multipart (#2304)
* Unsatisfied conditions will return AccessDenied instead of MissingFields * Require form-field `file` in POST policy and make `filename` an optional attribute * S3 feature: Replace in Key by filename attribute passed in multipart
This commit is contained in:
committed by
Harshavardhana
parent
2f7358a8a6
commit
8b3cb3a0de
@@ -99,29 +99,32 @@ func extractMetadataFromHeader(header http.Header) map[string]string {
|
||||
return metadata
|
||||
}
|
||||
|
||||
func extractHTTPFormValues(reader *multipart.Reader) (io.Reader, map[string]string, error) {
|
||||
func extractHTTPFormValues(reader *multipart.Reader) (io.Reader, string, map[string]string, error) {
|
||||
/// HTML Form values
|
||||
formValues := make(map[string]string)
|
||||
filePart := new(bytes.Buffer)
|
||||
fileName := ""
|
||||
var err error
|
||||
for err == nil {
|
||||
var part *multipart.Part
|
||||
part, err = reader.NextPart()
|
||||
if part != nil {
|
||||
if part.FileName() == "" {
|
||||
canonicalFormName := http.CanonicalHeaderKey(part.FormName())
|
||||
if canonicalFormName != "File" {
|
||||
var buffer []byte
|
||||
buffer, err = ioutil.ReadAll(part)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, "", nil, err
|
||||
}
|
||||
formValues[http.CanonicalHeaderKey(part.FormName())] = string(buffer)
|
||||
formValues[canonicalFormName] = string(buffer)
|
||||
} else {
|
||||
if _, err = io.Copy(filePart, part); err != nil {
|
||||
return nil, nil, err
|
||||
return nil, "", nil, err
|
||||
}
|
||||
fileName = part.FileName()
|
||||
}
|
||||
}
|
||||
}
|
||||
return filePart, formValues, nil
|
||||
return filePart, fileName, formValues, nil
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user