awaiting submissions from storage acc
This commit is contained in:
+134
-4
@@ -120,7 +120,7 @@ export const getBlobs = async (containerName, casefolderID) => {
|
||||
),
|
||||
});
|
||||
}
|
||||
console.log("blobObj:", blobObj);
|
||||
//console.log("blobObj:", blobObj);
|
||||
|
||||
return blobObj;
|
||||
};
|
||||
@@ -230,13 +230,46 @@ export const downloadProgressFile = async (
|
||||
);
|
||||
|
||||
const blobClient = containerClient.getBlobClient(blobName);
|
||||
console.log("herher:", containerName, blobName, casefolderID);
|
||||
const downloadedBlob = await blobClient.download(0);
|
||||
|
||||
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
||||
return downloaded;
|
||||
};
|
||||
|
||||
export const downloadAllProgressFiles = async (
|
||||
containerName,
|
||||
progressBlobObj
|
||||
) => {
|
||||
//console.log(progressBlobObj);
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const containerClient = new ContainerClient(
|
||||
`${STORAGE_PATH}/${containerName}`,
|
||||
creds
|
||||
);
|
||||
|
||||
let blobClient = {};
|
||||
let downloadedBlob = {};
|
||||
let downloaded = "";
|
||||
let blobCount = 0;
|
||||
|
||||
for (const prop in progressBlobObj) {
|
||||
//console.log(`${prop}: ${progressBlobObj[prop].path}`);
|
||||
blobClient = containerClient.getBlobClient(progressBlobObj[prop].path);
|
||||
downloadedBlob = await blobClient.download(0);
|
||||
downloaded =
|
||||
downloaded +
|
||||
(await streamToBuffer(downloadedBlob.readableStreamBody)) +
|
||||
",";
|
||||
blobCount++;
|
||||
}
|
||||
|
||||
downloaded = downloaded.substring(0, downloaded.length - 1);
|
||||
|
||||
//console.log(downloaded);
|
||||
return '{ "@odata.count": ' + blobCount + ',"value": [' + downloaded + "]}";
|
||||
};
|
||||
|
||||
const streamToBuffer = async (readableStream) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks = [];
|
||||
@@ -250,6 +283,42 @@ const streamToBuffer = async (readableStream) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getCaseBlob = async (
|
||||
containerName,
|
||||
caseReference,
|
||||
formContent
|
||||
) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const containerClient = new ContainerClient(
|
||||
`${STORAGE_PATH}/${containerName}`,
|
||||
creds
|
||||
);
|
||||
|
||||
console.log("have got to create case");
|
||||
containerClient.createIfNotExists();
|
||||
|
||||
let blobCount = 0;
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: caseReference,
|
||||
})) {
|
||||
blobCount++;
|
||||
}
|
||||
|
||||
const content = JSON.stringify(formContent);
|
||||
const blobName = caseReference + "/case/" + caseReference + ".json";
|
||||
|
||||
console.log("blobName:", blobName);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
|
||||
const uploadBlobResponse = await blockBlobClient.upload(
|
||||
content,
|
||||
Buffer.byteLength(content)
|
||||
);
|
||||
|
||||
return blobName;
|
||||
};
|
||||
|
||||
export const getProgressBlobs = async (containerName, caseReference) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
@@ -260,7 +329,15 @@ export const getProgressBlobs = async (containerName, caseReference) => {
|
||||
|
||||
containerClient.createIfNotExists();
|
||||
|
||||
console.log("thisi s the caasefolder:", caseReference);
|
||||
let blobCount = 0;
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: caseReference,
|
||||
})) {
|
||||
blobCount++;
|
||||
}
|
||||
|
||||
//console.log("this is the caasefolder:", caseReference, blobCount);
|
||||
|
||||
let blobObj = [];
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: caseReference + "/" + caseReference + ".json",
|
||||
@@ -304,7 +381,60 @@ export const getProgressBlobs = async (containerName, caseReference) => {
|
||||
},
|
||||
]).reverse()[0];
|
||||
|
||||
console.log("blobObj:", blobObj);
|
||||
//console.log("blobObjwwwww:", blobObj);
|
||||
|
||||
return blobObj;
|
||||
};
|
||||
|
||||
export const getAllProgressBlobs = async (containerName) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const containerClient = new ContainerClient(
|
||||
`${STORAGE_PATH}/${containerName}`,
|
||||
creds
|
||||
);
|
||||
|
||||
containerClient.createIfNotExists();
|
||||
|
||||
let blobCount = 0;
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
// prefix: caseReference,
|
||||
})) {
|
||||
blobCount++;
|
||||
}
|
||||
|
||||
//console.log("this is the caasefolder:", caseReference, blobCount);
|
||||
|
||||
let blobObj = [];
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
//prefix: caseReference + "/" + caseReference + ".json",
|
||||
})) {
|
||||
blob.name.split("/")[1].indexOf(".json") > 0 &&
|
||||
blob.name.split("/")[1].indexOf("undefined") < 0 &&
|
||||
blobObj.push({
|
||||
"name": blob.name.split("/")[1],
|
||||
"path": blob.name,
|
||||
"versionId": blob.versionId,
|
||||
"isCurrentVersion": blob.isCurrentVersion,
|
||||
"contentLength": blob.properties.contentLength,
|
||||
"contentType": blob.contentType,
|
||||
"lastModified": blob.properties.lastModified,
|
||||
// "hashedfilepath": hashAPIPath(
|
||||
// "/api/file/downloadblob?container=" +
|
||||
// containerName +
|
||||
// ),
|
||||
// "hasheddeletepath": hashAPIPath(
|
||||
// "/api/file/deleteblob?container=" +
|
||||
// containerName +
|
||||
// ),
|
||||
// "hashgetblobs": hashAPIPath(
|
||||
// "/api/file/getbloblist?container=" +
|
||||
// containerName +
|
||||
// ),
|
||||
});
|
||||
}
|
||||
|
||||
//console.log("blobObj:", blobObj);
|
||||
|
||||
return blobObj;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user