简体   繁体   English

Firebase和Swift:如何使用另一个数据库存储更大的文件?

[英]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. 我目前正在尝试使用Firebase构建一个聊天应用程序,同时使用Firebase进行实时消息传递。 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) 我唯一的问题是我希望用户发送图像,我希望他们拥有带图像的配置文件,但我知道Firebase的存储空间有限(或者至少每个支付层的存储空间对于你获得的连接数量来说很低)

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. 因此,当消息和图像发送时,而不是Firebase存储图像,它会将URL存储到另一个数据库中的图像。

I am under the impression something like AWS S3 is my best bet. 我认为像AWS S3这样的东西是我最好的选择。 any help is appreciated! 任何帮助表示赞赏!

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中查看和存储图像

Firebase has a 10Mb capacity, which is adequate for many images. Firebase的容量为10Mb,适用于许多图像。 However, if you need larger, they can be easily encoded as base64 and split into chunks. 但是,如果您需要更大,它们可以很容易地编码为base64并分成块。

If you want to go external: 如果你想去外部:

s3 or Filepicker (Filestack) as well as Google provide some options. s3或Filepicker (Filestack)以及Google提供了一些选项。

Not sure of the overall requirements but obviously you can dig into CloudKit / CoreData and even Dropbox offers an API. 不确定总体要求,但显然你可以深入了解CloudKit / CoreData,甚至Dropbox也提供API。

I have zero experience with Box but it may be an option as well. 我对Box没有经验,但它也可能是一个选项。

Each option has it's own API. 每个选项都有自己的API。

In general, you would store a link in a firebase node to the image/object in question. 通常,您会将firebase节点中的链接存储到相关图像/对象中。 However, the mechanics of that vary wildly as interfacing with CloudKit/CoreData will be different than say Filepicker. 然而,由于与CloudKit / CoreData的接口将与Filepicker不同,因此其机制变化很大。

With CoreData you will have to roll your own reference scheme whereas Filepicker you can have an almost direct reference to the file. 使用CoreData,您必须滚动自己的参考方案,而Filepicker可以对文件进行几乎直接的引用。

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 Swift2从Firebase检索图像

Once you get rolling, if you have issues post some code in another question. 一旦你开始滚动,如果你有问题在另一个问题中发布一些代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将文件上传到s3,然后将URL存储在Firebase中-Swift 2.2 - Uploading files to s3 and then storing the URL in Firebase - Swift 2.2 使用自动增量Swift 3在Firebase数据库中存储帖子(图像,标题) - Storing posts (image, caption) in Firebase database with auto increment Swift 3 FIREBASE数据库 - 存储子节点的唯一键(Swift / IOS) - FIREBASE Database - Storing Unique Key to child node(Swift/IOS) 如何从设置有Firebase的一个IOS App读取/写入另一个Firebase项目中包含的另一个Firebase数据库? 迅捷3 - How to read/write from one IOS App set up with firebase, to another firebase database contained in another firebase project? Swift 3 如何在Swift中使用PromiseKit和Firebase? - How to use PromiseKit with Firebase in Swift? Swift - 如何处理 Firebase 数据库错误代码 - Swift -how to handle Firebase Database Error Codes 如何在Firebase数据库中检查唯一的用户名(Swift) - How to check unique username in Firebase Database (swift) 如何在Swift中从Firebase数据库检索变量 - How to retrieve a variable from a Firebase Database in Swift Swift - Firebase 数据库如何推送通知? - Swift - Firebase Database How to push notification? 快速如何从Firebase数据库进行搜索 - swift how to make a search from firebase database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM