如何通过 android 将文件保存到 Firebase 托管文件夹位置以获取图像? [英] How do you save a file to a Firebase Hosting folder location for images through android?

查看:32
本文介绍了如何通过 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 托管文件夹位置以获取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆