简体   繁体   English

Firebase 存储,JSPDF 不保留图像

[英]Firebase Storage, JSPDF Not Keeping Images

I am building a PDF in JSPDF with react.我正在用 React 在 JSPDF 中构建一个 PDF。 I am adding an image to this pdf using takescreenshot() from ArcGIS API (it is an image of a map).我正在使用 ArcGIS API 中的 takescreenshot() 向此 pdf 添加图像(它是地图图像)。 After creating the PDF I can download it no problem, but if I upload the PDF to firebase storage and automate an email with the downloadURL from firebase storage, the PDF no longer has the image in it.创建 PDF 后,我可以毫无问题地下载它,但是如果我将 PDF 上传到 firebase 存储并使用来自 firebase 存储的 downloadURL 自动生成 email,则 PDF 中不再有图像。

I'm assuming there is some issue with firebase incorporating the image due to CORS, but I'm curious if anyone else has run into something like this.我假设 firebase 由于 CORS 合并图像存在一些问题,但我很好奇是否有其他人遇到过这样的事情。

Here is my code:这是我的代码:

var blob = pdf.output('blob');
var id = uuid();
var storageRef = firebase.storage().ref(`${userInfo.currentCompany}`);
var storageRefName = `${moment().format('YYYY-MM-DD')}_${userInfo.currentAccount}.pdf`;
var noSpaceRef = storageRefName.replace(/\s/g, '_');
var uploadTask = storageRef.child(noSpaceRef).put(blob);

uploadTask.on('state_changed', (snapshot) =>
{
  var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
  console.log(progress);
}, function (error)
{
  console.log(error);
}, () =>
{
  uploadTask.snapshot.ref.getDownloadURL().then((downloadURL) =>
  {
    this.sendEmail(downloadURL)

  });
});

Any help is appreciated!任何帮助表示赞赏!

When in doubt, make sure you're still passing the correct props.如有疑问,请确保您仍在传递正确的道具。 My blob was technically different when I would hit my download PDF button compared to email PDF button.与 email PDF 按钮相比,当我点击下载 PDF 按钮时,我的 blob 在技术上有所不同。

Classic.经典的。

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

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