简体   繁体   中英

Firebase Storage, JSPDF Not Keeping Images

I am building a PDF in JSPDF with react. I am adding an image to this pdf using takescreenshot() from ArcGIS API (it is an image of a map). 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.

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.

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.

Classic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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