MultipartFile class abstract interface

Represents a file uploaded via a multipart/form-data HTTP request.

This interface provides methods to access both metadata and content of uploaded files. It is used in controllers or services that handle file uploads in JetLeaf web applications.

A MultipartFile can be retrieved from a multipart request using a MultipartServerHttpRequest or similar abstraction. It supports:

  • Reading file content as bytes
  • Checking if a file is empty
  • Accessing metadata such as name, original filename, content type, and size
  • Transferring content directly to an OutputStream or storage destination

Example

Future<void> handleFileUpload(MultipartFile file) async {
  if (!file.isEmpty()) {
    print('Received file: ${file.getOriginalFilename()}');
    await file.transferTo(File('/tmp/${file.getOriginalFilename()}').openWrite());
  }
}
Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getInputStream() → InputStream
Returns a new InputStream to read the underlying content.
inherited
getName() String
Returns the name of the form field that the file was uploaded with.
getOriginalFilename() String
Returns the original filename of the uploaded file as supplied by the client.
getSize() int
Returns the size of the uploaded file in bytes.
isEmpty() bool
Returns true if the file is empty (zero bytes) or no file was uploaded.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
transferTo(OutputStream outputStream) Future<void>
Transfers the content of the file to the specified OutputStream.

Operators

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