Skip to main content

nhost_storage_dart 2.2.1 copy "nhost_storage_dart: ^2.2.1" to clipboard
nhost_storage_dart: ^2.2.1 copied to clipboard

Dart client for Nhost Storage with file upload, download, deletion, presigned URLs, and image transforms.

Nhost Storage Dart SDK #

Pub nhost_dart tests

Nhost Storage API for Dart

Getting Started #

Get your subdomain and region from nhost dashboard User Authentication is needed in order to upload.

import 'package:nhost_auth_dart/nhost_auth_dart.dart';
import 'package:nhost_storage_dart/nhost_storage_dart.dart';

void main() async {
  // Setup
  final auth = NhostAuthClient(url: authUrl);

  final storage = NhostStorageClient(
    url: storageUrl,
    // this must be passed form Auth session otherwise,
    // the sessions are not shared and therefore, headers for API calls
    // will be missed.
    session: auth.userSession,
  );

  await auth.signInEmailPassword(
    email: 'user-1@nhost.io',
    password: 'password-1',
  );

  // Create a new file...
  final fileMetadata = await storage.uploadString(
    fileName: 'some_text_file.txt',
    fileContents: 'abcdef abcdef abcdef abcdef abcdef',
    mimeType: 'text/plain',
  );
  print('File uploaded!');

  // ...turn around and download its contents...
  final downloadedFileContent = await storage.downloadFile(fileMetadata.id);
  print('Downloaded file contents:');
  print(downloadedFileContent.body);

  // ...then delete it.
  await storage.delete(fileMetadata.id);

  // Release
  auth.close();
  storage.close();
}

Latest Release #

dependencies:
  nhost_auth_dart: ^2.6.1
  nhost_storage_dart: ^2.2.0
3
likes
160
points
806
downloads

Documentation

API reference

Publisher

verified publishernhost.io

Weekly Downloads

Dart client for Nhost Storage with file upload, download, deletion, presigned URLs, and image transforms.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

http, http_parser, nhost_sdk

More

Packages that depend on nhost_storage_dart