在js中将多个文件上传到Firebase存储后如何获取url数组

时间:2019-12-24 19:05:06

标签: reactjs firebase firebase-storage

在将多个文件上传到Firebase存储后如何获取url数组。我正在使用以下代码,但它返回元数据数组。

firebase.storage().ref().constructor.prototype.putFiles = function(files) { 
  var ref = this;
  return Promise.all(files.map(function(file) {
  return ref.child(file.name).put(file);
  }));
}

// use it!
firebase.storage().ref().putFiles(files).then(function(metadatas) {
 // Get an array of file metadata
 }).catch(function(error) {
 // If any task fails, handle this
});

1 个答案:

答案 0 :(得分:0)

最简单的方法是在上传每个文件后返回元数据的下载URL

location
相关问题