You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP β†’
Socket
Book a DemoInstallSign in
Socket

@firebase/storage-compat

Package Overview
Dependencies
Maintainers
4
Versions
1354
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/storage-compat

The Firebase Firestore compatibility package

0.3.16
Source
npmnpm
Version published
Maintainers
4
Created

What is @firebase/storage-compat?

The @firebase/storage-compat package is designed for Firebase users who are migrating their projects to the new Modular Web SDK but still need to maintain compatibility with the older Firebase Storage API. It provides a compatibility layer that allows developers to use the Firebase Storage service in a way that's similar to the older 'namespaced' API, while under the hood it uses the modern Modular SDK. This package is particularly useful during the transition period for projects that are being gradually migrated to the new SDK.

What are @firebase/storage-compat's main functionalities?

Upload Files

This feature allows users to upload files to Firebase Storage. The code sample demonstrates how to import the necessary functions from the package, create a reference to a storage location, and then upload a file to that location.

import { getStorage, ref, uploadBytes } from '@firebase/storage-compat';

const storage = getStorage();
const storageRef = ref(storage, 'some-child');

// 'file' comes from the Blob or File API
tuploadBytes(storageRef, file).then((snapshot) => {
  console.log('Uploaded a blob or file!');
});

Download Files

This feature enables users to download files from Firebase Storage. The provided code shows how to obtain a reference to a file stored in Firebase and retrieve its download URL.

import { getStorage, ref, getDownloadURL } from '@firebase/storage-compat';

const storage = getStorage();
const pathReference = ref(storage, 'some/child');

getDownloadURL(pathReference)
  .then((url) => {
    // `url` is the download URL for the file
    console.log(url);
  });

List Files

This functionality allows users to list all files in a specified directory of Firebase Storage. The code example illustrates how to reference a directory and list all files within it.

import { getStorage, ref, listAll } from '@firebase/storage-compat';

const storage = getStorage();
const listRef = ref(storage, 'files/');

listAll(listRef)
  .then((res) => {
    res.items.forEach((itemRef) => {
      // All the items under listRef.
      console.log(itemRef);
    });
  });

Other packages similar to @firebase/storage-compat

FAQs

Package last updated on 06 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts