(file, password)
| 4522 | * |
| 4523 | */ |
| 4524 | export const decryptPdf = async (file, password) => { |
| 4525 | const name = generatePdfName(16); |
| 4526 | const baseApi = localStorage.getItem("baseUrl") || ""; |
| 4527 | const url = removeTrailingSegment(baseApi) + "/decryptpdf?ts=" + Date.now(); |
| 4528 | let formData = new FormData(); |
| 4529 | formData.append("file", file); |
| 4530 | formData.append("password", password); |
| 4531 | const config = { |
| 4532 | headers: { "content-type": "multipart/form-data" }, |
| 4533 | responseType: "blob" |
| 4534 | }; |
| 4535 | const response = await axios.post(url, formData, config); |
| 4536 | const pdfBlob = new Blob([response.data], { type: "application/pdf" }); |
| 4537 | return new File([pdfBlob], name, { type: "application/pdf" }); |
| 4538 | }; |
| 4539 | |
| 4540 | /** |
| 4541 | * Convert a Base64 string to a File object. |
no test coverage detected