Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeFiles ¶
func DecodeFiles( filesMap map[string][]*multipart.FileHeader, dest any) (stored []io.Closer, err error)
DecodeFiles binds the uploaded parts of a multipart form onto the matching fields of dest, returning the stored files so the caller can decide when to release them.
This is the documented way to receive an upload — declare a core.IFile field on the DTO — and it used to be the path with no content check at all: the hand-rolled FormFile and GetFiles applied an allowlist (to the type the *client* declared, which is a separate problem), and this applied none. The check now lives in model.NewMultipartFile, where it runs off the sniffed content for every path into storage; a part whose type is not allowed fails here with model.UploadTypeError instead of being written and bound.
The returned closers are the *stored* files, not the part readers. Each part reader is closed as soon as its content has been copied out, because nothing afterwards reads from it — the stored file reads from its own temp copy. The stored files, in contrast, must outlive this call: the field it was just bound to is what a handler publishes with Write, and Write reads the temp copy. See MultipartParser.releaseWithRequest.
Types ¶
type FieldBindError ¶ added in v2.2.0
FieldBindError reports a part that names a field the DTO cannot hold.
A local type rather than the http package's newValidationError, which is package-private there and would pull this decoder into an import cycle. The HTTP layer maps it — see MultipartParser.Parse — so the client gets the standard validation envelope naming the one field that was wrong, rather than the old fallback's one reason fanned across every part.
func (*FieldBindError) Error ¶ added in v2.2.0
func (e *FieldBindError) Error() string
type ValuesDecoder ¶
type ValuesDecoder struct {
// contains filtered or unexported fields
}
func NewFormValuesDecoder ¶
func NewFormValuesDecoder() *ValuesDecoder