【发布时间】:2017-06-15 18:59:10
【问题描述】:
我的 ionic 2 应用程序中有一个简单的功能,可以将文件上传到我的 firebase 存储服务器。它从相机中抓取图像的base64编码字符串,但是当我不尝试强制content-type时,它默认为application/octet-stream。当我尝试将元数据添加到 putString() 方法时,出现错误。
有谁知道我如何使用putString 做到这一点?
这是我目前的功能:
uploadProfilePhoto(file) {
this.storage.get('user').then(user => {
let id = user.id;
var metadata = {
contentType: 'image/jpeg',
};
let userProfileRef = this.fbStorage.ref(`/users/${id}/profile_photo/profile_photo.jpg`);
userProfileRef.putString(file, metadata).then(snapshot => {
}).catch(error => {
});
})
}
【问题讨论】:
标签: angular firebase ionic2 firebase-storage