Skip to content

File Storage

Dox file storage offers straightforward drivers for managing local file systems and extends the capability to develop custom drivers for cloud services like AWS or Digital Ocean Spaces.'/image/put', (DoxRequest req) async {
    /// get form-data image from request
    RequestFile file = req.input('image');

    /// store image to /storage/images folder
    String url = await Storage().put('images', await file.bytes);

    return url;



This function takes an instance of the RequestFile class as input and manages the storage of files. It is intended for handling files in a more structured manner, allowing you to work with file metadata, such as file name, content type, and other attributes, along with the file's binary data. This function is suitable for handling file uploads and storage in your application.

RequestFile file = req.input('image');

String url = await Storage().putRequestFile('images', file);


This function accepts a byte sequence as input and stores it. It is designed for saving raw binary data, such as images or binary files, directly to a storage.

RequestFile file = req.input('image');

String url = await Storage().put('images', file.bytes);


Retrieve the file in the form of a byte string.

List<int>? bytes = Storage().get('images/avatar/sample.jpeg');


Verify the file's existence.

List<int>? bytes = Storage().exists('images/avatar/sample.jpeg');


This function removes or erases the file.

List<int>? bytes = Storage().delete('images/avatar/sample.jpeg');


This function provides the file in a format that can be streamed.

StreamFile file = Storage().stream('images/avatar/sample.jpeg');


This function provides the file in a format that can be downloaded.

DownloadableFile file = Storage().download('images/avatar/sample.jpeg');

Custom file driver

To create a custom driver, you have the option to implement the StorageDriverInterface.

class YourCustomDriver implements StorageDriverInterface {

    Future<bool> exists(String filename) {


    Future<Uint8List?> get(String filename) async {


    Future<dynamic> delete(String filename) async {


    Future<String> put(String folder, List<int> bytes, { String? extension }) async {