android - How to upload array of image links to Firestore
问题描述
I just completed a blog app that allows a user to upload a single image as a post. I am using Firestore to save the image link from Cloud Storage
final StorageReference postPath.putFile(mainImageURI).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()){
downloadUri =
task.getResult().getDownloadUrl().toString();
Map<String, Object> map = new HashMap<>();
map.put("image_url", downloadUri);
{
However, i now intend to allow users upload multiple images for each post. Uploading the images to Cloud Storage is no problem for me. But how can i save an array of image links for one document child in Cloud Storage. I have not been able to figure this out. Please help.
解决方案
Firestore 具有字段的数组类型。只需使用您要编写的所有 URL 的字符串填充一个 ArrayList,并将其作为文档中您要存储它的字段的值。
推荐阅读
- javascript - 如何一次滚动一个服务部分,同时将 .service-inner 元素保持在同一个位置?
- php - 如何从地址字符串中提取城市州邮政编码?
- angular - 将我的 Angular 项目更新为 Angular 7 时出错
- sql - 使用相同 WHERE 子句的 SELECT 和 UPDATE 之间的不同结果
- jenkins-pipeline - 如何部署到 OpenShift 中的通用主机名?
- angular - Angular 元素与 Angular 库?
- php - PHP:如何阻止对音频文件的直接 URL 访问,但仍允许登录用户查看但不能下载?
- java - 客户端 服务器 java 套接字
- c++ - 使getline检查输入文件的第二行和第三行
- mysql - 如何在 Spring Boot 中读取 Blob