Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase & Swift: How to use another database for storing larger files?

I am currently trying to build a chat application in swift whilst using Firebase for real-time messaging. My only issue is I want users to send images, I want them to have profiles with images but I know Firebase has limited storage (or at least storage per pay tier is low for the number of connections you get)

So I would like to know how to connect up another database and make calls when needed between the two. So when and image is sent in a message, rather than Firebase storing the image, it stores a URL to the image in the other database.

I am under the impression something like AWS S3 is my best bet. any help is appreciated!

like image 868
Dom Bryan Avatar asked Feb 24 '16 14:02

Dom Bryan


People also ask

What is Firebase and how does it work?

Firebase is a product of Google which helps developers to build, manage, and grow their apps easily. It helps developers to build their apps faster and in a more secure way. No programming is required on the firebase side which makes it easy to use its features more efficiently. It provides services to android, ios, web, and unity.

Where can I find Firebase reference docs?

Formal reference documentation for Firebase SDKs, Firebase REST APIs, and Firebase tools. Find Firebase reference docs under the Reference tab at the top of the page. Fully working code to get started fast and see real-world integrations of Firebase features.

What is Firebase Cloud Messaging (FCM)?

Formerly known as Google Cloud Messaging (GCM), Firebase Cloud Messaging (FCM) is a cross-platform solution for messages and notifications for Android, iOS, and web applications, which as of 2016 can be used at no cost.

Does Google collect data through Firebase?

It stated that through Firebase, Google collected and stored user data, logging what the user was looking at in many types of apps, despite the user following Google's own instructions to turn off the web and app activity collected by the company. ^ Tamplin, James. "Firebase is Joining Google!".


1 Answers

This question has been asked before and there are a number of solutions. It's kind of an 'opinion' type question but here are a few options.

View and store images in Firebase

Firebase has a 10Mb capacity, which is adequate for many images. However, if you need larger, they can be easily encoded as base64 and split into chunks.

If you want to go external:

s3 or Filepicker (Filestack) as well as Google provide some options.

Not sure of the overall requirements but obviously you can dig into CloudKit / CoreData and even Dropbox offers an API.

I have zero experience with Box but it may be an option as well.

Each option has it's own API.

In general, you would store a link in a firebase node to the image/object in question. However, the mechanics of that vary wildly as interfacing with CloudKit/CoreData will be different than say Filepicker.

With CoreData you will have to roll your own reference scheme whereas Filepicker you can have an almost direct reference to the file.

Many of these services provide a free or low cost tryouts and you can whip some code up in a manner of a few minutes to test out the functionality to see if it may meet your requirement.

If you need help encoding/decoding, see the answer to this question

Swift2 retrieving images from Firebase

Once you get rolling, if you have issues post some code in another question.

like image 148
Jay Avatar answered Oct 18 '22 01:10

Jay