ApiFile class

A single file attachment for ApiBody.formData requests.

Exactly one of file (disk-based) or bytes (in-memory) must be provided.

// From a file on disk (e.g. image_picker result)
ApiFile(fieldName: 'avatar', file: File('/path/photo.jpg'))

// From raw bytes (e.g. web platform)
ApiFile(fieldName: 'doc', bytes: pdfBytes, filename: 'report.pdf')

Constructors

ApiFile({required String fieldName, File? file, List<int>? bytes, String? filename, String? mimeType})
Creates an ApiFile. Either file or bytes must be provided.
const

Properties

bytes List<int>?
Raw bytes for the file. Use on web or when you already have the bytes.
final
fieldName String
The form field name, e.g. "avatar" or "document".
final
file File?
File read from disk. Use with image_picker or file_picker results.
final
filename String?
Optional filename override sent in the multipart header. If null, the file's basename is used.
final
hashCode int
The hash code for this object.
no setterinherited
mimeType String?
Optional MIME type, e.g. "image/jpeg" or "application/pdf".
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited