delete reps on dash
This commit is contained in:
+38
-3
@@ -494,6 +494,41 @@ export const deleteBlobCase = async (containerName, blobName) => {
|
||||
return { "deleted": blobName };
|
||||
};
|
||||
|
||||
export const deleteBlobRep = async (containerName, blobName) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const options = {
|
||||
deleteSnapshots: "include", // or 'only'
|
||||
};
|
||||
|
||||
const containerToken = await createContainerSas(containerName);
|
||||
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||
const containerClient = new ContainerClient(sasUrl);
|
||||
|
||||
console.log("blob to delete:", blobName);
|
||||
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: blobName,
|
||||
})) {
|
||||
console.log("------ :", blob.name);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blob.name);
|
||||
console.log("=======:", await blockBlobClient.exists());
|
||||
|
||||
(await blockBlobClient.exists()) &&
|
||||
containerClient.deleteBlob(blob.name);
|
||||
|
||||
//containerClient.deleteIfExists();
|
||||
//containerClient.deleteBlob(blob.name);
|
||||
}
|
||||
|
||||
// containerClient.deleteBlob(blobName);
|
||||
// console.log(`deleted blob ${blobName}`);
|
||||
// for await (const blob of containerClient.listBlobsFlat()) {
|
||||
// console.log(" ------ :", blob.name);
|
||||
// }
|
||||
return { "deleted": blobName };
|
||||
};
|
||||
|
||||
export const uploadFile = async (formContent, containerName, foldername) => {
|
||||
const containerToken = await createContainerSas(containerName);
|
||||
const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
|
||||
@@ -887,7 +922,7 @@ export const downloadAllRepsFiles = async (containerName, repsBlobObj) => {
|
||||
console.log("is empt and an array");
|
||||
|
||||
for (const prop in repsBlobObj) {
|
||||
//console.log(`Progress - ${prop}: ${repsBlobObj[prop].path}`);
|
||||
console.log(`Progress - ${prop}: ${repsBlobObj[prop].path}`);
|
||||
blobClient = containerClient.getBlobClient(repsBlobObj[prop].path);
|
||||
downloadedBlob = await blobClient.download(0);
|
||||
let repBlobObj = await streamToBuffer(
|
||||
@@ -1100,7 +1135,7 @@ export const getRepsBlobs = async (containerName) => {
|
||||
for await (const blob of containerClient.findBlobsByTags(
|
||||
"blobType='Representation'"
|
||||
)) {
|
||||
console.log(`-----Blob ${blobCount++}: ${blob.name}`);
|
||||
console.log(`-----Get Rep Blob ${blobCount++}: ${blob.name}`);
|
||||
blobCount++;
|
||||
}
|
||||
|
||||
@@ -1122,7 +1157,7 @@ export const getRepsBlobs = async (containerName) => {
|
||||
"blobType='Representation'",
|
||||
listOptions
|
||||
)) {
|
||||
const blobClient = await containerClient.getBlobClient(blob.name);
|
||||
const blobClient = containerClient.getBlobClient(blob.name);
|
||||
console.log("getreps blob:", blob);
|
||||
blob.name.split("/")[2].indexOf("_rep.json") > 0 &&
|
||||
blob.name.split("/")[2].indexOf("undefined") < 0 &&
|
||||
|
||||
Reference in New Issue
Block a user