最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - How to get image data in blob format from Ionic Capacitor - Stack Overflow

programmeradmin4浏览0评论

I'm using Ionic/Capacitor (with Angular) to retrieve image data from Android Gallery. Using Capacitor.getPhoto to retrieve image data, but the data is in Base64. Ultimate goal is to send and save image data in Blob form to a Node.js server and split the image into multiple pieces using Canvas. I'm currently able to accomplish all of this using the Base64 data from Capacitor.getPhoto. But that creates a really large image file on the Node.js server. So if I can send image data to the Node.js server in Blob form, I'm hoping it would reduce the image file size. This is what my Angular code looks like currently:

from(Camera.getPhoto({
  quality: 100,
  allowEditing: false,
  resultType: CameraResultType.Uri
})).pipe(
  concatMap((resp) => from(Filesystem.readFile({path: resp.path}))),
  catchError((error) => {throw new Error(error.message)})
).subscribe({
  next: (resp) => this.httpService.sendRequest(uri, resp),
  error: (error) => console.log('error: ', error)
})

I'm not sure how to proceed so that the argument "resp" to httpService.sendRequest (to send data to Node.js) is data in Blob format, not Base64String format. Appreciate some guidance on this.

发布评论

评论列表(0)

  1. 暂无评论