如何通过 android 将文件保存到 Firebase 托管文件夹位置以获取图像?

How do you save a file to a Firebase Hosting folder location for images through android?(如何通过 android 将文件保存到 Firebase 托管文件夹位置以获取图像?)
本文介绍了如何通过 android 将文件保存到 Firebase 托管文件夹位置以获取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Firebase 的新手,目前正在研究如何实施它.我在想它具有类似于 Parse 的功能,其中可以创建一个 ParseFile 对象来保存文件,然后具有上传它的功能,如下所示:

I'm really new to Firebase and am studying how to implement it right now. I was thinking that it has functions similar to Parse where a ParseFile object can be created that holds the file and then has functions to upload it something like the following :

ParseFile parseFile = new ParseFile(file);
parseFile.saveInBackground();

如果您有建议和/或可行的解决方案,请发布它们,因为它们将非常有用.

If you have suggestions and/or working solutions do post them as they will be exceptionally useful.

我也在研究 RetroFit,因为它有一种发送 MultiPartPost 请求的好方法,如果可以与 Firebase 绑定,我只是找不到连接.

I am also studying about RetroFit as it has a great way of sending MultiPartPost requests and if ever could be tied up with Firebase I just can't find the connection yet.

提前致谢!

推荐答案

Firebase 托管是一种托管静态资产的服务,通常是网站的 HTML/CSS/图像.您不能以编程方式将文件添加到 Firebase 托管.

Firebase Hosting is a service for hosting static assets, typically the HTML/CSS/images of a web site. You cannot programmatically add files to Firebase Hosting.

Firebase 数据库允许您存储 JSON 数据.虽然二进制数据不是 JSON 支持的类型,但可以使用 base64 对二进制数据进行编码,从而将图像存储在(大)字符串中.请参阅 我可以使用 Java API 将图像文件存储在 firebase 中吗? 请注意,虽然这是可能的,但不建议将其用于小图像或好奇是否可以这样做.

The Firebase Database allows you to store JSON data. While binary data is not a type that is supported in JSON, it is possible to encode the binary data in say base64 and thus store the image in a (large) string. See Can I store image files in firebase using Java API? Note that while this is possible, it is not recommended for anything but small images or as a curiosity to see that it can be done.

您的最佳选择通常是将图像存储在第 3 方图像存储服务上.

Your best option is typically to store the images on a 3rd party image storage service.

这篇关于如何通过 android 将文件保存到 Firebase 托管文件夹位置以获取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)