更新时间:2023-01-15 13:10:04
这是我使用 angularfire 2 进行文件上传过程的编码方式.
Here is the way that I coded using angularfire 2 for the file uploading process.
public selectedFile: FileList;
chooseFile(event) {
this.selectedFile = event.target.files;
}
uploadImage() {
const file = this.selectedFile.item(0);
const key = 'uploads/' + '/' + Math.floor(Math.random() * 1000000) + file.name;
const upload = this.stroge.upload(key, file).then(() => {
const ref = this.stroge.ref(key);
const downloadURL = ref.getDownloadURL().subscribe(url => {
this.Updateprofile(url);
});
});
}