Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Firebase存储:“getDownloadURL”中的参数计数无效:应为0个参数,收到1个_Angular_Url_Firebase_Ionic Framework_Firebase Storage - Fatal编程技术网

Angular Firebase存储:“getDownloadURL”中的参数计数无效:应为0个参数,收到1个

Angular Firebase存储:“getDownloadURL”中的参数计数无效:应为0个参数,收到1个,angular,url,firebase,ionic-framework,firebase-storage,Angular,Url,Firebase,Ionic Framework,Firebase Storage,我正在尝试在上传图像后立即获取图像的下载url,我的代码如下所示: let image : string = 'promo_' + this.username + '_' + new Date() + '.png', storageRef : any, parseUpload : any; return new Promise((resolve, reject) => { storageRef = fire

我正在尝试在上传图像后立即获取图像的下载url,我的代码如下所示:

    let image       : string  = 'promo_' + this.username + '_' + new Date() + '.png',
      storageRef  : any,
      parseUpload : any;

    return new Promise((resolve, reject) => {

      storageRef       = firebase.storage().ref('/promos/' + image);
      parseUpload      = storageRef.putString(this.imageHolder, 'data_url');

      parseUpload.on('state_changed', (_snapshot) => {
          // We could log the progress here IF necessary
          console.log('snapshot progess ' + _snapshot);
        },
        (_err) => {
           reject(_err);
           console.log(_err.messsage);
        },
        (success) => {
           resolve(parseUpload.snapshot); 
        })
      }).then(value => {

          storageRef.getDownloadURL(url => {
          this.list = this.af.list('/promos');
          this.list.subscribe(items => {
            let metadata = {
              customMetadata: {
                'title': this.item.title,
                'caption': this.item.caption,
                'price': this.item.price,
                'date': this.item.date,
                'typeofselect': this.item.typeofselect,
                'username': this.username,
                'url': url
              }
            }
            items.push(metadata);
          })
        }).catch(e => console.log(e.message);

      }).catch(function(error) {
        console.log(error.message);
      });
错误是:

Firebase存储:“getDownloadURL”中的参数计数无效:应为0个参数,收到1个


我获取下载url的方式是否有问题?谢谢。

您不应该将回调函数传递给,因为它不带参数。它返回一个包含URL的字符串。在中,解析时可以访问URL


是的,谢谢你的帮助
storageRef.getDownloadURL()
.then(url => {
    // Do something...
});