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