【发布时间】:2018-11-09 19:48:00
【问题描述】:
我正在尝试在我的 Angular Firebase/Firestore 应用程序中构建上传功能。我正在使用本教程:
https://angularfirebase.com/lessons/firebase-storage-with-angularfire-dropzone-file-uploader/
并从 Atom 的 linter 中获取此错误消息:
Property 'downloadURL' does not exist on type 'AngularFireUploadTask'.
我的file-upload.component.ts 的相关部分如下。请参阅标有ERROR HERE 的代码。
import { Component, OnInit } from '@angular/core';
import { AngularFireStorage, AngularFireUploadTask } from 'angularfire2/storage';
import { AngularFirestore} from 'angularfire2/firestore';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-file-upload',
templateUrl: './file-upload.component.html',
styleUrls: ['./file-upload.component.css']
})
export class FileUploadComponent implements OnInit {
// Main Task
task: AngularFireUploadTask;
// download URL
downloadURL: Observable<string>;
// state for dropzone CSS toggling
isHovering: boolean;
constructor(private storage: AngularFireStorage, private db: AngularFirestore) { }
startUpload(event: FileList) {
//the file object
const file = event.item(0)
...
// the storage path
const path = `test/${new Date().getTime()}_${file.name}`;
// The main task
this.task = this.storage.upload(path, file, {customMetadata})
// ERROR HERE
this.downloadURL = this.task.downloadURL();
}
ngOnInit() {
}
}
【问题讨论】:
标签: javascript angular typescript firebase angularfire2