mirror of
https://github.com/pgsty/minio.git
synced 2026-10-09 11:15:57 +03:00
api: Handle content-length-range policy properly. (#3297)
content-length-range policy in postPolicy API was
not working properly handle it. The reflection
strategy used has changed in recent version of Go.
Any free form interface{} of any integer is treated
as `float64` this caused a bug where content-length-range
parsing failed to provide any value.
Fixes #3295
This commit is contained in:
+11
-3
@@ -470,14 +470,22 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
|
||||
return
|
||||
}
|
||||
|
||||
// Use limitReader to ensure that object size is within expected range.
|
||||
// Use rangeReader to ensure that object size is within expected range.
|
||||
lengthRange := postPolicyForm.Conditions.ContentLengthRange
|
||||
if lengthRange.Valid {
|
||||
// If policy restricted the size of the object.
|
||||
fileBody = limitReader(fileBody, int64(lengthRange.Min), int64(lengthRange.Max))
|
||||
fileBody = &rangeReader{
|
||||
Reader: fileBody,
|
||||
Min: lengthRange.Min,
|
||||
Max: lengthRange.Max,
|
||||
}
|
||||
} else {
|
||||
// Default values of min/max size of the object.
|
||||
fileBody = limitReader(fileBody, 0, maxObjectSize)
|
||||
fileBody = &rangeReader{
|
||||
Reader: fileBody,
|
||||
Min: 0,
|
||||
Max: maxObjectSize,
|
||||
}
|
||||
}
|
||||
|
||||
// Save metadata.
|
||||
|
||||
Reference in New Issue
Block a user