reps pdf upload directory restructure
This commit is contained in:
+63
-55
@@ -276,16 +276,11 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
|
||||
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";
|
||||
const blobName = caseref + "/" + formContent.repfile_name + "_rep.json";
|
||||
|
||||
console.log("blobName:", blobName);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
@@ -297,7 +292,7 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
|
||||
|
||||
const tags = {
|
||||
containerid: containerName,
|
||||
caseID: caseID,
|
||||
caseID: formContent.caseRef,
|
||||
blobType: "Representation",
|
||||
};
|
||||
|
||||
@@ -378,13 +373,18 @@ export const uploadFile = async (formContent, containerName, foldername) => {
|
||||
files[prop][0].path,
|
||||
files[prop].size
|
||||
);
|
||||
|
||||
console.log(
|
||||
"////////////////////////\nfile name:",
|
||||
files[prop][0].fieldName,
|
||||
"\n////////////////////////////"
|
||||
);
|
||||
|
||||
const tags = {
|
||||
containerid: containerName,
|
||||
caseID: foldername,
|
||||
documentType: files[prop][0].fieldName.slice(
|
||||
0,
|
||||
files[prop][0].fieldName.indexOf("_")
|
||||
),
|
||||
caseID: foldername.split("/")[0],
|
||||
documentType: files[prop][0].fieldName.split(".")[1],
|
||||
blobType: "RepresentationFile",
|
||||
};
|
||||
const withTags = await blockBlobClient.setTags(tags);
|
||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
@@ -410,21 +410,17 @@ export const uploadRepFiles = async (
|
||||
console.log(...formContent);
|
||||
console.log("rep files...", files, Object.keys(files).length, foldername);
|
||||
|
||||
// console.log(`files[${prop}] = ${files[prop][0].size}`);
|
||||
const blobName = foldername + formContent.split("tmp/")[1];
|
||||
|
||||
console.log(blobName);
|
||||
|
||||
const blobName = foldername + "/" + formContent.split("tmp/")[1];
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
const uploadBlobResponse = await blockBlobClient.uploadFile(formContent);
|
||||
const tags = {
|
||||
containerid: containerName,
|
||||
caseID: foldername,
|
||||
documentType: "rep content",
|
||||
caseID: formContent.split("tmp/")[0],
|
||||
documentType: "Rep docs",
|
||||
};
|
||||
console.log(tags);
|
||||
// const withTags = await blockBlobClient.setTags(tags);
|
||||
// const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
const withTags = await blockBlobClient.setTags(tags);
|
||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
|
||||
console.log(
|
||||
`Uploaded block blob ${files} successfully`,
|
||||
@@ -432,11 +428,10 @@ export const uploadRepFiles = async (
|
||||
);
|
||||
};
|
||||
|
||||
export const uploadPDFRepFiles = async (
|
||||
export const uploadPDFCaseFiles = async (
|
||||
formContent,
|
||||
containerName,
|
||||
foldername,
|
||||
repType
|
||||
foldername
|
||||
) => {
|
||||
const containerToken = await createContainerSas(containerName);
|
||||
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||
@@ -446,28 +441,20 @@ export const uploadPDFRepFiles = async (
|
||||
|
||||
console.log(formContent, containerName, foldername);
|
||||
console.log(
|
||||
"rep pdf files...",
|
||||
"case pdf files...",
|
||||
files,
|
||||
Object.keys(files).length,
|
||||
foldername
|
||||
);
|
||||
|
||||
// console.log(`files[${prop}] = ${files[prop][0].size}`);
|
||||
console.log(foldername + "/files/" + formContent.split("tmp/")[1]);
|
||||
|
||||
const blobName = foldername + "/files/" + formContent.split("tmp/")[1];
|
||||
|
||||
console.log(blobName);
|
||||
|
||||
console.log(blobName);
|
||||
const blobName = foldername + "/" + formContent.split("tmp/")[1];
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
const uploadBlobResponse = await blockBlobClient.uploadFile(formContent);
|
||||
|
||||
const tags = {
|
||||
containerid: containerName,
|
||||
caseID: foldername,
|
||||
documentType: repType,
|
||||
blobType: "RepresentationPDF",
|
||||
caseID: foldername.split("/")[0],
|
||||
blobType: "AppealPDF",
|
||||
};
|
||||
|
||||
console.log("the tags:", tags);
|
||||
@@ -481,7 +468,7 @@ export const uploadPDFRepFiles = async (
|
||||
};
|
||||
|
||||
export const downloadFile = async (containerName, blobName) => {
|
||||
//console.log.apply(containerName, blobName);
|
||||
//console.log(containerName, blobName);
|
||||
const containerToken = await createContainerSas(containerName);
|
||||
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||
const containerClient = new ContainerClient(sasUrl);
|
||||
@@ -497,7 +484,7 @@ export const downloadProgressFile = async (
|
||||
blobName,
|
||||
casefolderID
|
||||
) => {
|
||||
//console.log.apply(containerName, blobName);
|
||||
console.log(containerName, blobName);
|
||||
|
||||
const containerToken = await createContainerSas(containerName);
|
||||
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||
@@ -624,7 +611,7 @@ export const downloadAllRepsFiles = async (containerName, repsBlobObj) => {
|
||||
|
||||
repBlobObj = JSON.parse(repBlobObj);
|
||||
|
||||
repBlobObj["casereference"] = repsBlobObj[prop].name.split("/")[0];
|
||||
repBlobObj["casereference"] = repsBlobObj[prop].name.split("/")[1];
|
||||
|
||||
// repBlobObj = JSON.stringify(repBlobObj);
|
||||
|
||||
@@ -682,6 +669,17 @@ export const getCaseBlob = async (
|
||||
content,
|
||||
Buffer.byteLength(content)
|
||||
);
|
||||
|
||||
const tags = {
|
||||
containerid: containerName,
|
||||
caseID: caseReference,
|
||||
blobType: "Case",
|
||||
};
|
||||
|
||||
console.log("the tags:", tags);
|
||||
const withTags = await blockBlobClient.setTags(tags);
|
||||
const withMeta = await blockBlobClient.setMetadata(tags);
|
||||
|
||||
return blobName;
|
||||
};
|
||||
|
||||
@@ -699,22 +697,22 @@ export const getProgressBlobs = async (containerName, caseReference) => {
|
||||
blobCount++;
|
||||
}
|
||||
|
||||
// console.log(
|
||||
// "this is the casefolder and blobcount:",
|
||||
// caseReference,
|
||||
// blobCount
|
||||
// );
|
||||
console.log(
|
||||
"this is the casefolder and blobcount:",
|
||||
caseReference,
|
||||
blobCount
|
||||
);
|
||||
|
||||
let blobObj = [];
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: caseReference + "/" + caseReference + "_appeal.json",
|
||||
})) {
|
||||
//console.log("getProgressBlobs in here");
|
||||
console.log("getProgressBlobs in here", blob.name.split("/"));
|
||||
blobObj.push({
|
||||
"name": blob.name.split("/")[1],
|
||||
"path": blob.name,
|
||||
"versionId": blob.versionId,
|
||||
"caseObj": caseReference + "/" + caseReference + "_case.json",
|
||||
"caseObj": caseReference + "/case/" + caseReference + "_case.json",
|
||||
"isCurrentVersion": blob.isCurrentVersion,
|
||||
"contentLength": blob.properties.contentLength,
|
||||
"contentType": blob.contentType,
|
||||
@@ -771,16 +769,16 @@ export const getAllProgressBlobs = async (containerName) => {
|
||||
blobObj.push({
|
||||
"name": blob.name.split("/")[1],
|
||||
"path": blob.name,
|
||||
"versionId": blob.versionId,
|
||||
//"versionId": blob.versionId,
|
||||
"caseObj":
|
||||
blob.name.split("/")[0] +
|
||||
"/case/" +
|
||||
blob.name.split("/")[0] +
|
||||
"_case.json",
|
||||
"isCurrentVersion": blob.isCurrentVersion,
|
||||
"contentLength": blob.properties.contentLength,
|
||||
"contentType": blob.contentType,
|
||||
"lastModified": blob.properties.lastModified,
|
||||
// "isCurrentVersion": blob.isCurrentVersion,
|
||||
// "contentLength": blob.properties.contentLength,
|
||||
// "contentType": blob.contentType,
|
||||
// "lastModified": blob.properties.lastModified,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -810,16 +808,26 @@ export const getRepsBlobs = async (containerName) => {
|
||||
blobCount
|
||||
);
|
||||
|
||||
const listOptions = {
|
||||
includeMetadata: true,
|
||||
includeSnapshots: false,
|
||||
includeTags: true,
|
||||
includeVersions: true,
|
||||
};
|
||||
|
||||
let blobObj = [];
|
||||
for await (const blob of containerClient.findBlobsByTags(
|
||||
"blobType='Representation'"
|
||||
"blobType='Representation'",
|
||||
listOptions
|
||||
)) {
|
||||
const blobClient = await containerClient.getBlobClient(blob.name);
|
||||
console.log(blob);
|
||||
blob.name.split("/")[1].indexOf("_rep.json") > 0 &&
|
||||
blob.name.split("/")[1].indexOf("undefined") < 0 &&
|
||||
blob.name.split("/")[2].indexOf("_rep.json") > 0 &&
|
||||
blob.name.split("/")[2].indexOf("undefined") < 0 &&
|
||||
blobObj.push({
|
||||
"name": blob.name.split("/")[1],
|
||||
"name": blob.name.split("/")[2],
|
||||
"path": blob.name,
|
||||
"size": blobClient.getProperties().contentLength,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1497,6 +1497,20 @@ export const downloadBlob = (containerName, blobName) => {
|
||||
};
|
||||
|
||||
export const getProgressFromBlob = async (containerName, casereference) => {
|
||||
console.log(
|
||||
/////////////////\ngetProgressFromBlob",
|
||||
BASE_URL +
|
||||
"/api/file/getprogressobjblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casereference +
|
||||
hashAPIPath(
|
||||
"/api/file/getprogressobjblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casereference
|
||||
)
|
||||
);
|
||||
try {
|
||||
const res = await axios.get(
|
||||
BASE_URL +
|
||||
|
||||
Reference in New Issue
Block a user