我一直在尝试使用我的Ionic应用程序将照片上传到Firebase . 我能够使用AngularFire处理数据库服务,但在尝试使用存储时似乎遇到了问题 .
我在app.module.ts中用firebase初始化了我的应用程序...
@NgModule({
declarations: [
MyApp
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(FIREBASE_CONFIG),
AngularFireAuthModule,
AngularFireDatabaseModule,
AngularFirestoreModule,
AngularFireStorageModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp
],
providers: [
StatusBar,
SplashScreen,
FileChooser,
File,
Geolocation,
Camera,
{ provide: ErrorHandler, useClass: IonicErrorHandler },
AuthService,
DataService
]
})
在我的编辑 Profiles 页面中,我有一个功能,我希望用户能够上传 Profiles 照片,该功能看起来像这样......
async takePhoto()
{
try
{
// Defining camera options
const options: CameraOptions =
{
quality: 50,
targetHeight: 600,
targetWidth: 600,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
// take picture with camera
const result = await this.camera.getPicture(options)
const image = `data:image/jpeg;base64,${result}`;
const pictures = this.afStorage.ref('Profile Pictures');
pictures.putString(image, 'data_url');
}
catch(e)
{
console.error(e);
}
}
似乎问题发生在我引用afStorage的地方 . 该程序运行没有错误,但该文件不会出现在我的Firebase存储中 . 有没有办法我可以调试这个或者是否有人能够帮我解决我的问题?
谢谢