updated rep pdf to stream
This commit is contained in:
@@ -361,7 +361,7 @@ export const createRepPDFBlob = async (
|
||||
const content = formContent;
|
||||
|
||||
//console.log(content);
|
||||
const blobName = caseID + "/files/" + repName + ".pdf";
|
||||
const blobName = caseID + "/" + repName + "/files/" + repName + ".pdf";
|
||||
|
||||
console.log("blobName:", blobName);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
@@ -378,7 +378,7 @@ export const createRepPDFBlob = async (
|
||||
const withTags = await blockBlobClient.setTags(tags);
|
||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
|
||||
return formContent.pinswg_name;
|
||||
return uploadBlobResponse;
|
||||
};
|
||||
|
||||
export const deleteBlob = async (containerName, blobName) => {
|
||||
|
||||
@@ -69,10 +69,9 @@ const RepComplete = (props) => {
|
||||
<Link
|
||||
href="/myportal"
|
||||
onClick={() => setRepresentationReset()}
|
||||
className="govuk-button">
|
||||
|
||||
className="govuk-button"
|
||||
>
|
||||
{t("common:continue-button")}
|
||||
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -196,12 +196,4 @@ export default async function handler(req, res) {
|
||||
path: `/files/${blobProgress.pinswg_name}.pdf`,
|
||||
});
|
||||
});
|
||||
|
||||
// return res.status(200).json({
|
||||
// data: "success",
|
||||
// path: process.cwd() + `/tmp/${blobProgress.pinswg_name}.pdf`,
|
||||
// });
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ import {
|
||||
createRepBlob,
|
||||
uploadFile,
|
||||
uploadPDFRepFiles,
|
||||
createRepPDFBlob,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
|
||||
@@ -208,16 +209,16 @@ export default async function handler(req, res) {
|
||||
// code block
|
||||
}
|
||||
|
||||
console.log(
|
||||
"///////////////////////////////////\n file created: \n" +
|
||||
process.cwd() +
|
||||
`tmp/${reqBodyobj.repfile_name}.pdf` +
|
||||
"\n folder:" +
|
||||
process.cwd() +
|
||||
"\n/////////////////////////"
|
||||
);
|
||||
// console.log(
|
||||
// "///////////////////////////////////\n file created: \n" +
|
||||
// process.cwd() +
|
||||
// `tmp/${reqBodyobj.repfile_name}.pdf` +
|
||||
// "\n folder:" +
|
||||
// process.cwd() +
|
||||
// "\n/////////////////////////"
|
||||
// );
|
||||
|
||||
const renderedPDF = await ReactPDF.renderStream(
|
||||
const renderedPDF = await ReactPDF.renderToStream(
|
||||
<MyDocument docProps={reqBodyobj} />
|
||||
);
|
||||
|
||||
@@ -226,30 +227,16 @@ export default async function handler(req, res) {
|
||||
containerID,
|
||||
caseRef,
|
||||
reqBodyobj.repfile_name
|
||||
);
|
||||
|
||||
console.log(
|
||||
"///////////////////////////////////\nrep pdf file created: " +
|
||||
`/files/${reqBodyobj.repfile_name}.pdf`,
|
||||
"\n/////////////////////////"
|
||||
);
|
||||
|
||||
// upload file to storage account
|
||||
// uploadPDFRepFiles(
|
||||
// process.cwd() + `/tmp/${reqBodyobj.repfile_name}.pdf`,
|
||||
// containerID,
|
||||
// caseRef + "/" + reqBodyobj.repfile_name,
|
||||
// repType
|
||||
// );
|
||||
|
||||
// remove from local folder
|
||||
//fs.unlinkSync(process.cwd() + `/tmp/${reqBodyobj.repfile_name}.pdf`);
|
||||
|
||||
return res.status(200).json({
|
||||
data: "success",
|
||||
path: `${reqBodyobj.repfile_name}.pdf`,
|
||||
).then((data) => {
|
||||
console.log(
|
||||
"///////////////////////////////////\nrep pdf file created: " +
|
||||
`${caseRef}/files/${reqBodyobj.repfile_name}.pdf`,
|
||||
"\n/////////////////////////"
|
||||
);
|
||||
return res.status(200).json({
|
||||
status: "success",
|
||||
data: data,
|
||||
path: `${caseRef}/${reqBodyobj.repfile_name}/files/${reqBodyobj.repfile_name}.pdf`,
|
||||
});
|
||||
});
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user