Save documents in Firebase storage

Currently in the process of developing a web application using Firebase and Angularjs as my frontend tools. Curious to know whether it's feasible to store various file types within the Firebase DB.

Could you shed some light on any potential limitations I may encounter?

Appreciate your assistance!

Answer №1

When sending data from your client to Firebase, it gets serialized into a JSON object. This means you're limited to storing types that can be represented with JSON primitives:

  • Strings (Unicode)
  • Booleans
  • Numbers (64 bit floating point)
  • null

If your browser supports the File API and you can convert a file to one of the above types, then yes, you can store it in Firebase (as long as it's under 10mb).

For files encoded with Unicode, simply read them into string variables and pass them to Firebase like any other string.

Working with binary files is more complex.

Consider images. You can use the readAsDataURL method to get a base64 encoded string which can be serialized to JSON for storage in Firebase. When retrieving the image data, other users can display it using the src='data:image/png;base64, syntax.

An example project utilizing this technique can be found here.

A more intricate case would involve a binary file format such as Midi. While you can read the file into a base64 string, browsers cannot play it directly, so users will need to download it. Providing a base64 string won't work either, as most Midi players are unable to interpret it.

To address this, you'll have to create a decoder to convert the base64 data back into binary before saving it to file or offering it for download. This process usually requires converting it into a blob using typed arrays.

Answer №2

Google's Firebase platform recently introduced Storage, a feature that is distinct from the Realtime Database. Unlike the database, Storage does not have Angular bindings. It can conveniently handle files larger than 10mb without requiring any encoding.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting attributes on an AngularJS Directive element in real time

My goal is to create a directive in AngularJS with a template that can contain other AngularJS directives. All of my directives require an "id" attribute, so I must set the "id" on the directive within the template. However, no matter how I attempt this, A ...

Displaying unique input values with ng-model

Within the controller, there is a variable that monitors the page index (starting at 0) for a paginated table: var page { pageNumber: 0; } Query: How can I display this pageNumber variable in the HTML, but always incremented by +1? (since the index=0 p ...

Internet Explorer versions 9 and 10 do not support the CSS property "pointer-events: none"

In Firefox, the CSS property pointer-events: none; functions properly. However, it does not work in Internet Explorer 9-10. Are there any alternative approaches to replicate the functionality of this property in IE? Any suggestions? ...

Expand the data retrieved from the database in node.js to include additional fields, not just the id

When creating a login using the code provided, only the user's ID is returned. The challenge now is how to retrieve another field from the database. I specifically require the "header" field from the database. Within the onSubmit function of the for ...

NodeJS: Retrieve Over 10,000 Images From the Server

Attempting to retrieve over 10,000 images from a server led me to create this script: const http = require('http') const fs = require('fs') const opt = { agent: new http.Agent({ keepAlive: true, maxSockets: 5 }), headers ...

Incorporating a PHP file containing both PHP and JavaScript variables into an AJAX document

I'm facing an issue with my application that involves a language file called "lang.php", along with "index.php" and "ajax.php" files. The "lang.php" file contains both PHP and JavaScript variables which I include in both "index.php" and "ajax.php" to ...

What steps can be taken to ensure that all object properties become reactive?

Let's dive into this simplified scenario: interface Pup { name: string; age: number; } const puppy: Pup = { name: 'Rex', age: 3, }; The goal here is to establish a reactive link for each attribute within the puppy object. The usua ...

transferring data to and from a secure website

Excuse my confusion, but I am feeling a bit overwhelmed with this situation. My coworkers and I have been working on a project where I developed a website using HTTPS, while another colleague set up a webserver. To access my website, I found that I can typ ...

Establish communication between two Sails applications

I am currently working on a Sails.js project that features a member portal with all possible routes and actions. However, I am considering developing a CMS using Sails as well. Originally, my plan was to integrate the CMS into the existing project, but n ...

The angular.copy() function cannot be used within angular brackets {{}}

Within my controller, I am utilizing the "as vm" syntax. To duplicate one data structure into a temporary one, I am employing angular.copy(). angular.copy(vm.data, vm.tempData = []) Yet, I have a desire to transfer this code to the template view so that ...

Tips for displaying specific HTML elements in AngularJS using ng-repeat and ng-if

I am working with some bootstrap HTML code that includes an ng-repeat function. <div class="row"> <div class="col-lg-4" ng-repeat="p in persons"> <img class="img-circle" src="images/{{ p.image }}" width="140" height="140"> < ...

Oops! You can only have one parent element in JSX expressions

I'm working on creating a password input box, but I keep encountering an error when integrating it into my JS code. Here's the snippet of my code that includes TailwindCSS: function HomePage() { return ( <div> <p className=&q ...

Updating a JSON file with new object using node.js

Currently, I am attempting to insert a single object into an extensive JSON file. My approach involves parsing the entire file using FS and JSON.Parse, adding the new JSON object in memory, and then rewriting the file. While I am aware of FS's append ...

The AngularJS ui-bootstrap modal challenge with instances

Encountering an issue with my AngularJS app (version 1.4.7) and the latest version of ui.bootstrap. The problem arises when attempting to inject $uibModalInstance, resulting in the error message Unknown provider: $uibModalInstanceProvider Below is the con ...

Executing a cURL request using Node.js

Looking for assistance in converting the request below: curl -F <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a777f7e737b275a73777b7d7f34706a7d">[email protected]</a> <url> to an axios request if possible. ...

Retrieving the user's uid who deleted a document from Firestore using Cloud Functions

Currently, I am facing a challenge in obtaining the UID of an authenticated user who deletes a document in Firestore within an onWrite cloud function. This issue does not occur in real-time database as it has different functionalities. The purpose behind t ...

Utilize the Angular 1 function again

Imagine you have two sets of items: available items and associated items. I need to create a search function that utilizes different API methods to search each list separately. After obtaining the search results, I must store them in models using the $scop ...

Utilizing Google APIs to split a route among multiple locations

I am facing a scenario where A laundry company operates from one shop location. The laundry company has 3 trucks available (n trucks). The laundry company needs to deliver washed clothes to multiple locations (n locations). Using the Google Directions AP ...

Conceal a different CSS class if a certain CSS class is present on the page

I am currently working on organizing my page to distinguish between purchased and unsold products. For the items that have been bought, I am using the CSS class "winning_bid" within a div element. My goal is to hide another div with the class "price" if th ...

Having trouble retrieving data from mailosaur using protractor, even though it works fine with node.js

I've been trying to incorporate Protractor code with mailosaur for handling email functionality but I'm facing issues retrieving the value while coding in Protractor. Surprisingly, when I run the same code in node.js it works perfectly fine and I ...