Skip to main content

dox_storage 3.0.0-alpha.5 copy "dox_storage: ^3.0.0-alpha.5" to clipboard
dox_storage: ^3.0.0-alpha.5 copied to clipboard

File storage for the dox framework. One API for local disk, AWS S3 and S3-compatible services (R2, MinIO, Spaces), with swappable drivers.

dox_storage #

File storage for Dart. One API for local disk, AWS S3 and S3-compatible services.

pub package license: MIT

Part of Dox, a web backend framework for Dart, like Laravel. Source code: github.com/dartondox/dox.

Install #

dart pub add dox_storage

Dox 3.x is in alpha (3.0.0-alpha.4). The API can still change before the stable release.

Use it #

import 'dart:typed_data';

import 'package:dox_storage/dox_storage.dart';

void main() async {
  DriveManager drive = DriveManager(
    defaultDisk: 'local',
    disks: <String, DriverContract>{
      'local': LocalDriver(LocalDriverConfig(root: 'storage')),
      's3': S3Driver(S3DriverConfig(
        bucket: 'my-bucket',
        region: 'us-east-1',
        accessKeyId: 'AKIA...',
        secretAccessKey: '...',
      )),
    },
  );

  Disk disk = drive.use(); // the default disk
  await disk.put('notes/a.txt', 'hello');
  Uint8List data = await disk.get('notes/a.txt');
  print(await disk.exists('notes/a.txt')); // true
  await disk.delete('notes/a.txt');
}

In a Dox app, set the disks in config/storage.dart and use Storage().

Features #

  • Drivers: LocalDriver, S3Driver (AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces, GCS with HMAC keys) and MemoryDriver.
  • put, putStream, get, getStream, copy, move, delete, listAll.
  • Signed download URLs, and signed upload URLs on S3.
  • Big streams go up as a multipart upload. Only one part is in memory at a time.
  • Keys are checked. .., absolute paths and null bytes throw InvalidKeyException.
  • drive.fake('s3') swaps a disk for memory in tests.
  • AWS Signature V4 is written in this package. There is no AWS SDK dependency.

Documentation #

License #

MIT. See LICENSE.

0
likes
160
points
0
downloads

Publisher

verified publisherdartondox.dev

Weekly Downloads

File storage for the dox framework. One API for local disk, AWS S3 and S3-compatible services (R2, MinIO, Spaces), with swappable drivers.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

crypto, http, mime, path

More

Packages that depend on dox_storage