Skip to main content

dart_smb2 0.4.0 copy "dart_smb2: ^0.4.0" to clipboard
dart_smb2: ^0.4.0 copied to clipboard

Dart SMB2/3 client built on libsmb2, with listings, streaming reads, atomic downloads, uploads, copies, watches and cancellation. macOS, Windows, Linux, iOS and Android.

example/example.dart

// Minimal dart_smb2 example
import 'package:dart_smb2/dart_smb2.dart';

Future<void> main() async {
  // Connect a pool of worker isolates to a share.
  final pool = await Smb2Pool.connect(
    host: '192.168.1.10',
    share: 'Music',
    user: 'alice',
    password: 'secret',
  );

  try {
    // List the share's root.
    for (final entry in await pool.listDirectory('')) {
      print(entry.isDirectory ? '${entry.name}/' : entry.name);
    }

    // Download a file to disk, atomically.
    await pool.downloadToFile('Album/01 - Intro.flac', '/tmp/intro.flac');

    // Watch a directory while files go in.
    final changes = pool
        .watch('Backup', recursive: true)
        .listen((e) => print('${e.action.name} ${e.path}'));

    // Create the missing directories, upload a file and copy it.
    await pool.mkdir('Backup/2026/11', recursive: true);
    await pool.uploadFile(
      '/tmp/intro.flac',
      'Backup/2026/11/intro.flac',
      onProgress: (sent, total) => print('$sent / $total'),
    );
    await pool.copy(
      'Backup/2026/11/intro.flac',
      'Backup/latest.flac',
      overwrite: true,
    );

    await Future<void>.delayed(const Duration(seconds: 1));
    await changes.cancel();
  } on Smb2Exception catch (e) {
    print('${e.type.name}: ${e.message}');
  } finally {
    await pool.disconnect();
  }
}
8
likes
0
points
12.1k
downloads

Publisher

verified publisherales-drnz.com

Weekly Downloads

Dart SMB2/3 client built on libsmb2, with listings, streaming reads, atomic downloads, uploads, copies, watches and cancellation. macOS, Windows, Linux, iOS and Android.

Repository (GitHub)
View/report issues

Topics

#cross-platform #smb2 #smb3 #samba #libsmb2

License

unknown (license)

Dependencies

code_assets, crypto, ffi, hooks, meta

More

Packages that depend on dart_smb2