Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoFileUploaded = NewFileUploadError("NO_FILE", "No file was uploaded", "file") ErrFileTooLarge = NewFileUploadError("FILE_TOO_LARGE", "File size exceeds limit", "file") ErrInvalidFileType = NewFileUploadError("INVALID_TYPE", "File type not allowed", "file") ErrTooManyFiles = NewFileUploadError("TOO_MANY_FILES", "Too many files uploaded", "file") ErrInvalidFileContent = NewFileUploadError("INVALID_CONTENT", "File content is invalid", "file") )
Common file upload errors
Functions ¶
func GetFormValue ¶
GetFormValue extracts a form value
func NewFileUploadResponse ¶
func NewFileUploadResponse(files FileList, message string) *struct{ Body FileUploadResponseBody }
NewFileUploadResponse creates a standard response from uploaded files
Types ¶
type File ¶
type File struct {
// Filename is the original name of the uploaded file
Filename string `json:"filename" doc:"Original filename"`
// Size is the file size in bytes
Size int64 `json:"size" doc:"File size in bytes"`
// ContentType is the MIME type of the uploaded file
ContentType string `json:"content_type" doc:"MIME type of the file"`
// Content provides access to the file data
Content io.ReadCloser `json:"-"`
}
File represents an uploaded file with metadata
func GetFileFromForm ¶
GetFileFromForm extracts a single file from multipart form
func NewFile ¶
func NewFile(fh *multipart.FileHeader) (*File, error)
NewFile creates a new File from a multipart file header
func (*File) IsDocument ¶
IsDocument checks if the file is a document
type FileInfo ¶
type FileInfo struct {
Filename string `json:"filename" doc:"Original filename"`
Size int64 `json:"size" doc:"File size in bytes"`
ContentType string `json:"content_type" doc:"MIME type"`
URL string `json:"url,omitempty" doc:"URL to access the file"`
ID string `json:"id,omitempty" doc:"Unique file identifier"`
}
FileInfo contains metadata about an uploaded file
type FileList ¶
type FileList []*File
FileList represents a collection of uploaded files
func NewFileList ¶
func NewFileList(fhs []*multipart.FileHeader) (FileList, error)
NewFileList creates a new FileList from a slice of multipart file headers
type FileUploadError ¶
type FileUploadError struct {
Message string `json:"message"`
Code string `json:"code"`
Field string `json:"field,omitempty"`
}
FileUploadError represents an error that occurred during file upload
func NewFileUploadError ¶
func NewFileUploadError(code, message, field string) *FileUploadError
NewFileUploadError creates a new file upload error
func (*FileUploadError) Error ¶
func (e *FileUploadError) Error() string
func (*FileUploadError) GetHeaders ¶
func (e *FileUploadError) GetHeaders() map[string][]string
GetHeaders implements huma.HeadersError interface
func (*FileUploadError) GetStatus ¶
func (e *FileUploadError) GetStatus() int
Implement huma.StatusError interface for proper HTTP status codes
type FileUploadResponseBody ¶
type FileUploadResponseBody struct {
Message string `json:"message" doc:"Upload result message"`
Files []*FileInfo `json:"files" doc:"Information about uploaded files"`
TotalCount int `json:"total_count" doc:"Total number of files uploaded"`
TotalSize int64 `json:"total_size" doc:"Total size of all uploaded files"`
UploadedAt string `json:"uploaded_at" doc:"Upload timestamp"`
Metadata map[string]string `json:"metadata,omitempty" doc:"Additional metadata"`
}
FileUploadResponse provides a standard response structure for file uploads