x_storage_firebase

A package that provides Firebase Storage provider for XStorage. It enables file operations such as saving, loading, and deleting files using Firebase Storage.

Features

  • XStorage provider implementation for Firebase Storage
  • File save, load, delete, and existence check operations
  • Compliance with Firebase Storage security rules

Getting Started

Installation

dependencies:
  x_storage_firebase: ^0.0.1
  x_storage_core: ^0.0.1
  firebase_storage: ^11.2.6

Firebase Initialization

First, set up your Firebase project and perform the necessary initialization:

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:x_storage_firebase/x_storage_firebase.dart';
import 'package:x_storage_core/x_storage_core.dart';

// Initialize Firebase
await Firebase.initializeApp();

// Create XStorage instance
final storage = XStorage();

// Register Firebase Storage provider
final firebaseStorage = FirebaseStorage.instance;
storage.registerProvider(FirebaseStorageProvider(firebaseStorage: firebaseStorage));

Basic Usage

// Save a file
await storage.saveFile(
  XUri.create('firebase', 'path/to/file.txt'),
  Uint8List.fromList([/* data */]),
);

// Load a file
final data = await storage.loadFile(
  XUri.create('firebase', 'path/to/file.txt'),
);

// Delete a file
await storage.deleteFile(
  XUri.create('firebase', 'path/to/file.txt'),
);

// Check if a file exists
final exists = await storage.exists(
  XUri.create('firebase', 'path/to/file.txt'),
);

Security

  • Configure appropriate Firebase Storage security rules
  • Use Firebase Authentication for operations that require authentication
  • Implement proper access control when handling sensitive data

License

This project is licensed under the MIT License - see the LICENSE file for details.

Libraries

x_storage_firebase