Last updated:
0 purchases
nhost storage dart
Nhost Storage Dart SDK #
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: '[email protected]',
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();
}
copied to clipboard
Latest Release #
dependencies:
nhost_auth_dart: ^2.0.0
nhost_storage_dart: ^2.0.0
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.