multiple file upload issues capped at 210mb for now

This commit is contained in:
2024-12-10 15:09:04 +00:00
parent b2e1c01dea
commit dcb6171dc1
10 changed files with 475 additions and 119 deletions
+129
View File
@@ -521,10 +521,123 @@ export const uploadFile = async (formContent, containerName, foldername) => {
const containerClient = new ContainerClient(sasUrl);
const files = formContent;
let blobResponseArr = [];
//console.log(...formContent);
console.log("files...", files, Object.keys(files).length, foldername);
for (const prop in files) {
console.log(`files[${prop}] = ${files[prop][0].size}`);
const blobName = foldername + "/files/" + files[prop][0].fieldName;
console.log(blobName);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadBlobResponse = await blockBlobClient
.uploadFile(files[prop][0].path, files[prop].size)
.then((data) => {
console.log(
"////////////////////////\nfile name:",
files[prop][0].fieldName,
"\n////////////////////////////"
);
console.log(data);
let whichLocation =
files[prop][0].fieldName.indexOf("_Statement_of_Case") >
0 ||
files[prop][0].fieldName.indexOf("_-_Statement_of_Case") >
0 ||
files[prop][0].fieldName.indexOf("_-_Application_Form") >
0 ||
files[prop][0].fieldName.indexOf(
"_-_Site_Ownership_Certificate"
) > 0 ||
files[prop][0].fieldName.indexOf("_-_Decision_Notice") >
0 ||
files[prop][0].fieldName.indexOf("_-_Site_Location_Plan") >
0 ||
files[prop][0].fieldName.indexOf(
"_-_Plans_Drawing_Documents"
) > 0 ||
files[prop][0].fieldName.indexOf(
"_-_Additional_Plans_Drawings_Documents"
) > 0 ||
files[prop][0].fieldName.indexOf(
"_-_Design_and_Access_Statement"
) > 0 ||
files[prop][0].fieldName.indexOf(
"_-_NSB_LPA_Additional_Documents"
) > 0 ||
files[prop][0].fieldName.indexOf("_-_LPA_Correspondence") >
0 ||
files[prop][0].fieldName.indexOf(
"_-_LPA_Original_Permission"
) > 0 ||
files[prop][0].fieldName.indexOf(
"_-_LPA's_Registration_Letter"
) > 0 ||
files[prop][0].fieldName.indexOf(
+"_-_Environmental_Statement"
) > 0 ||
files[prop][0].fieldName.indexOf("_-_Cost_of_Application") >
0 ||
files[prop][0].fieldName.indexOf(
"_-_Other_Relevant_Material"
) > 0 ||
files[prop][0].fieldName.indexOf(
"_-_S106_Agreement_or_Unilateral_Undertaking" > 0
)
? "846040000"
: files[prop][0].fieldName.indexOf("_IP_") > 0
? "846040005"
: files[prop][0].fieldName.indexOf("_Statement_") > 0
? "846040002"
: files[prop][0].fieldName.indexOf("_Questionnaire_") >
0
? "846040001"
: files[prop][0].fieldName.indexOf("_Comments_") > 0
? "846040003"
: files[prop][0].fieldName.indexOf("_Impact_") > 0
? "846040001"
: "846040000";
const tags = {
containerid: containerName,
caseID: foldername.split("/")[0],
documentType: files[prop][0].fieldName.split(".")[1],
blobType: "RepresentationFile",
ishareLocation: whichLocation,
};
const withTags = blockBlobClient.setTags(tags);
const withMeta = blockBlobClient.setMetadata(tags);
console.log(
`Uploaded block blob ${files[prop][0].fieldName} successfully`
//uploadBlobResponse.requestId
);
blobResponseArr.push({ file: files[prop][0].fieldName });
});
}
return blobResponseArr;
};
export const uploadSingleFile = async (
formContent,
containerName,
foldername
) => {
const containerToken = await createContainerSas(containerName);
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
const containerClient = new ContainerClient(sasUrl);
const files = formContent;
//console.log(...formContent);
console.log("files...", files, Object.keys(files).length, foldername);
let blobResponseArr = [];
for (const prop in files) {
console.log(`files[${prop}] = ${files[prop][0].size}`);
const blobName = foldername + "/files/" + files[prop][0].fieldName;
@@ -534,6 +647,17 @@ export const uploadFile = async (formContent, containerName, foldername) => {
const uploadBlobResponse = await blockBlobClient.uploadFile(
files[prop][0].path,
files[prop].size
// {
// blobHTTPHeaders: {
// blobContentType: "application/octet-stream",
// },
// onProgress: (progress) => {
// // Log upload progress, you can emit this back to the client
// console.log(
// `Progress: ${progress.loadedBytes} bytes uploaded`
// );
// },
// }
);
console.log(
@@ -600,7 +724,12 @@ export const uploadFile = async (formContent, containerName, foldername) => {
`Uploaded block blob ${files[prop][0].fieldName} successfully`,
uploadBlobResponse.requestId
);
blobResponseArr.push({ file: files[prop][0].fieldName });
// return uploadBlobResponse;
}
return blobResponseArr;
};
export const uploadRepFiles = async (