-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Hi GoFr team! 👋
I'm using GoFr (v1.46.0) and currently have single file upload working perfectly. However, I'd like to extend this functionality to support multiple file uploads in a single request, and I'm not sure about the best approach with GoFr's context binding system.
Current Implementation (Single File Upload)
DTO Structure:
type FileUploadDTO struct {
File *multipart.FileHeader `file:"file"`
}Handler:
func (h *FileHandler) UploadFile(ctx *gofr.Context) (any, error) {
var upload dto.FileUploadDTO
if err := ctx.Bind(&upload); err != nil {
return nil, err
}
...
}This works great for single files, but I need to support multiple files in one request.
What I'm Looking For
-
Does GoFr's
ctx.Bind()support binding multiple files automatically? For example, would something like this work:type MultiFileUploadDTO struct { Files []*multipart.FileHeader `file:"files"` }
Actually I tried this approach but didn't work properly
- Is there a recommended GoFr pattern for handling bulk file uploads with proper error handling and validation?
Use Case
Users need to upload multiple trip photos/documents simultaneously (e.g., 5-10 files at once) rather than making individual requests for each file.
Environment
- GoFr Version: 1.46.0
- Go Version: 1.25
Any guidance or examples would be greatly appreciated! Thanks for the awesome framework! 🚀