Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@firebase/storage

Package Overview
Dependencies
Maintainers
4
Versions
3307
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@firebase/storage

This is the Cloud Storage component of the Firebase JS SDK.

  • 0.13.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1M
increased by5.49%
Maintainers
4
Weekly downloads
 
Created

What is @firebase/storage?

@firebase/storage is a Firebase service that provides a powerful, simple, and cost-effective object storage solution for web and mobile applications. It allows developers to upload, download, and manage files such as images, videos, and other user-generated content directly from their applications.

What are @firebase/storage's main functionalities?

Upload Files

This feature allows you to upload files to Firebase Storage. The code sample demonstrates how to upload a simple text file to a specified storage reference.

const { getStorage, ref, uploadBytes } = require('@firebase/storage');
const storage = getStorage();
const storageRef = ref(storage, 'some-child');
const file = new Blob(['Hello, world!'], { type: 'text/plain' });
uploadBytes(storageRef, file).then((snapshot) => {
  console.log('Uploaded a blob or file!');
});

Download Files

This feature allows you to download files from Firebase Storage. The code sample demonstrates how to get the download URL for a file stored in Firebase Storage.

const { getStorage, ref, getDownloadURL } = require('@firebase/storage');
const storage = getStorage();
const storageRef = ref(storage, 'some-child');
getDownloadURL(storageRef).then((url) => {
  console.log('File available at', url);
});

Delete Files

This feature allows you to delete files from Firebase Storage. The code sample demonstrates how to delete a file from a specified storage reference.

const { getStorage, ref, deleteObject } = require('@firebase/storage');
const storage = getStorage();
const storageRef = ref(storage, 'some-child');
deleteObject(storageRef).then(() => {
  console.log('File deleted successfully');
}).catch((error) => {
  console.error('Error deleting file:', error);
});

List Files

This feature allows you to list all files within a specified directory in Firebase Storage. The code sample demonstrates how to list all files under a specific storage reference.

const { getStorage, ref, listAll } = require('@firebase/storage');
const storage = getStorage();
const listRef = ref(storage, 'some-child');
listAll(listRef).then((res) => {
  res.items.forEach((itemRef) => {
    console.log('Item:', itemRef.name);
  });
}).catch((error) => {
  console.error('Error listing files:', error);
});

Other packages similar to @firebase/storage

FAQs

Package last updated on 14 Nov 2024

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