RequestFile class

An uploaded file from a multipart/form-data request.

Small files (up to 1 MB) are kept in memory. Bigger files are streamed to a temp file while the request is read, so a big upload does not fill the RAM. The temp file is deleted when the response is done, so call store() (from dox_storage) or moveTo before you return from the controller.

Implemented types

Constructors

RequestFile({required String filename, required String filetype, required int length, Uint8List? bytes, File? file, List<int>? head})

Properties

bytes → Future<Uint8List>
get file content in bytes. for a big file this reads the whole file into memory, so prefer stream, store() (from dox_storage) or moveTo for big files.
no setter
extension → String
Get file extension eg. png, jpeg, pdf
no setteroverride
file → File?
the file on disk, or null when the file is kept in memory
no setter
filename → String
final
filetype → String
final
hashCode → int
The hash code for this object.
no setterinherited
the first bytes of the file. @Mimes and @Image read the real file type from them, and @Dimensions reads the image size. a file in memory gives all its bytes (no copy). a file on disk gives its first 128 KB, so the size of a JPEG after its photo metadata is still found.
no setteroverride
length → int
size of the file in bytes
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → Future<num>
get file size in kilobytes
no setter

Methods

moveTo(String destination) → Future<File>
move the file to destination and return the new file. the first move of a temp file is a cheap rename, later calls copy, so the file can be stored in many places.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stream() → Stream<List<int>>
read the file content as a stream, without loading it all in memory
toString() → String
A string representation of this object.
inherited

Operators

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