This commit is contained in:
2022-12-16 11:36:01 +00:00
parent f6d934d951
commit 98aefdd867
36 changed files with 1258 additions and 371 deletions
+39 -1
View File
@@ -255,6 +255,44 @@ export const createBlob = async (formContent, containerName, caseref) => {
return formContent.pinswg_name;
};
export const createRepBlob = async (formContent, containerName, caseref) => {
const containerToken = await createContainerSas(containerName);
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
const containerClient = new ContainerClient(sasUrl);
formContent = JSON.parse(formContent);
let caseID = "";
caseID = _.has(formContent, "pinswg_name")
? formContent.pinswg_name
: caseref;
const content = JSON.stringify(formContent);
console.log(content);
const blobName = caseref + "/" + caseID + "_rep.json";
console.log("blobName:", blobName);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadBlobResponse = await blockBlobClient.upload(
content,
Buffer.byteLength(content)
);
const tags = {
containerid: containerName,
caseID: caseID,
blobType: "Representation",
};
console.log("the tags:", tags);
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
return formContent.pinswg_name;
};
export const deleteBlob = async (containerName, blobName) => {
const creds = new DefaultAzureCredential();
@@ -545,7 +583,7 @@ export const getAllProgressBlobs = async (containerName) => {
let blobObj = [];
for await (const blob of containerClient.listBlobsFlat()) {
blob.name.split("/")[1].indexOf(".json") > 0 &&
blob.name.split("/")[1].indexOf("_appeal.json") > 0 &&
blob.name.split("/")[1].indexOf("undefined") < 0 &&
blobObj.push({
"name": blob.name.split("/")[1],