Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@firebase/storage-compat
Advanced tools
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.
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);
});
});
The AWS SDK for JavaScript provides a similar set of functionalities for Amazon S3, another cloud storage service. While @firebase/storage-compat is specifically tailored for Firebase Storage, aws-sdk offers a broader range of services including but not limited to storage, making it a more versatile choice for projects that use multiple AWS services.
Azure Storage SDK for JavaScript is designed for use with Azure Blob Storage. Similar to @firebase/storage-compat, it allows for uploading, downloading, and listing blobs in storage containers. The main difference lies in the cloud provider, with azure-storage being focused on Microsoft's Azure platform.
This is the Cloud Storage component of the Firebase JS SDK.
This package is not intended for direct usage, and should only be used via the officially supported firebase package.
FAQs
The Firebase Firestore compatibility package
The npm package @firebase/storage-compat receives a total of 1,171,598 weekly downloads. As such, @firebase/storage-compat popularity was classified as popular.
We found that @firebase/storage-compat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.