Skip to content

Commit cbdd729

Browse files
fix: pdf download is not working
1 parent d5cc6f6 commit cbdd729

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

apps/OpenSign/src/components/pdf/PdfHeader.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useNavigate } from "react-router-dom";
99
import { themeColor } from "../../constant/const";
1010
import axios from "axios";
1111
import ModalUi from "../../primitives/ModalUi";
12-
import Parse from "parse";
12+
import { appInfo } from "../../constant/appinfo";
1313

1414
function Header({
1515
isPdfRequestFiles,
@@ -64,7 +64,19 @@ function Header({
6464
event.preventDefault();
6565

6666
try {
67-
const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
67+
// const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
68+
const axiosRes = await axios.post(
69+
`${appInfo.baseUrl}/functions/getsignedurl`,
70+
{ url: pdfUrl },
71+
{
72+
headers: {
73+
"content-type": "Application/json",
74+
"X-Parse-Application-Id": appInfo.appId,
75+
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
76+
}
77+
}
78+
);
79+
const url = axiosRes.data.result;
6880
const pdf = await getBase64FromUrl(url);
6981
const isAndroidDevice = navigator.userAgent.match(/Android/i);
7082
const isAppleDevice =
@@ -94,7 +106,19 @@ function Header({
94106
const handleDownloadPdf = async () => {
95107
const pdfName = pdfDetails[0] && pdfDetails[0].Name;
96108
try {
97-
const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
109+
// const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl });
110+
const axiosRes = await axios.post(
111+
`${appInfo.baseUrl}/functions/getsignedurl`,
112+
{ url: pdfUrl },
113+
{
114+
headers: {
115+
"content-type": "Application/json",
116+
"X-Parse-Application-Id": appInfo.appId,
117+
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
118+
}
119+
}
120+
);
121+
const url = axiosRes.data.result;
98122
saveAs(url, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`);
99123
} catch (err) {
100124
console.log("err in getsignedurl", err);
@@ -577,8 +601,13 @@ function Header({
577601
handleClose={() => setIsCertificate(false)}
578602
>
579603
<div className="p-3 md:p-5 text-[13px] md:text-base text-center">
580-
<p>Your completion certificate is being generated. Please wait momentarily.</p>
581-
<p>If the download doesn&apos;t start shortly, click the button again.</p>
604+
<p>
605+
Your completion certificate is being generated. Please wait
606+
momentarily.
607+
</p>
608+
<p>
609+
If the download doesn&apos;t start shortly, click the button again.
610+
</p>
582611
</div>
583612
</ModalUi>
584613
</div>

0 commit comments

Comments
 (0)