New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/storage-compat

Package Overview
Dependencies
Maintainers
4
Versions
1152
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.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-16.38%
Maintainers
4
Weekly downloads
 
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 16 Jan 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc