Skip to main content

firebase_storage_dart 0.2.2 copy "firebase_storage_dart: ^0.2.2" to clipboard
firebase_storage_dart: ^0.2.2 copied to clipboard

Unofficial pure-Dart client of Cloud Storage for Firebase: references, metadata, listing, downloads and uploads over the Firebase Storage REST API.

example/main.dart

// Quick start: upload a string, read it back and delete it.
//
// Shows: a FirebaseStorage on the local emulator, putString, getBytes, delete.
// Platform: Dart VM (the package itself also runs on the web).
// Run: FIREBASE_STORAGE_EMULATOR_HOST=127.0.0.1:9199 dart run example/main.dart
// Backend: Storage emulator, project demo-test (see common.dart for how to
// start it).
//
// The other files in this directory show one topic each: upload_bytes_and_strings.dart,
// resumable_upload.dart, streamed_download.dart, files.dart, list_and_paging.dart,
// metadata.dart, download_url.dart, error_handling.dart and emulator_and_auth.dart.

import 'dart:convert';

import 'package:firebase_storage_dart/firebase_storage_dart.dart';

import 'common.dart';

Future<void> main() async {
  final FirebaseStorage storage = emulatorStorage();
  // A reference is only a path; ref() and child() make no request.
  final Reference object = storage.ref(freshFolder('main')).child('hello.txt');
  try {
    final FullMetadata uploaded = await object.putString(
      'hello',
      metadata: const SettableMetadata(contentType: 'text/plain'),
    );
    print('${uploaded.fullPath}: ${uploaded.size} bytes');

    final bytes = await object.getBytes();
    print('read back: ${utf8.decode(bytes)}');
  } finally {
    // Remove what this example wrote, and end the client.
    await object.delete();
    storage.close();
  }
}
0
likes
160
points
396
downloads

Documentation

API reference

Publisher

verified publisherupcode.dev

Weekly Downloads

Unofficial pure-Dart client of Cloud Storage for Firebase: references, metadata, listing, downloads and uploads over the Firebase Storage REST API.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#firebase #storage #dart #server

License

Apache-2.0 (license)

Dependencies

firebase_app_dart, http, meta

More

Packages that depend on firebase_storage_dart