简体   繁体   English

图片上传不正确,Angular 8 和 ngx-image-compress

[英]The image not upload correctly, Angular 8 and ngx-image-compress

This is the problem这就是问题

I need to compress the image before to upload in storage of Firebase, I'm using ngx-image-compress.我需要先压缩图像才能上传到 Firebase 的存储中,我使用的是 ngx-image-compress。

The image yes upload to Storage of Firebase but it don't see.图片是上传到 Firebase 的存储,但看不到。

In my code I'm using the next method (compressFile) of ngx-image-compress library在我的代码中,我使用了 ngx-image-compress 库的下一个方法(compressFile)

this.imageCompress.compressFile( event.target.result, 50, 50).then( result => {
  this.imagenComprimida = result;  
  this.guardarImagen(result); //This function call the Firestore method putString() to upload image b64
});

The variable imagenComprimida yes show it in html but not in Firestore Storage.变量imagenComprimida yes 在 html 中显示,但在 Firestore 存储中不显示。

I don't understand why.我不明白为什么。

Also I tryed convert to File with the next method but it doesn't work either.我也尝试使用下一种方法转换为文件,但它也不起作用。

let imageFile = new File([result], "any", { type: 'image/jpeg' });

I hope you can help me.我希望你能帮助我。

SOLVED!!解决了!!

ngx-image-compress library has problems with Firestore. ngx-image-compress 库与 Firestore 存在问题。 I don´t not why.我不知道为什么。

I found ng2-img-max and this library runs without problems.我发现 ng2-img-max 并且这个库运行没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM