server v1.0.7

This commit is contained in:
2020-10-01 20:21:01 +02:00
parent 5d6c7d5e3f
commit 63c2fb88e0
6 changed files with 33 additions and 37 deletions

View File

@@ -1,4 +1,5 @@
import azureBlob from "@azure/storage-blob";
import e from "express";
import getStream from "into-stream";
import { newError } from "./services.js";
@@ -77,10 +78,18 @@ export function setDeleteTempBlobTimer(blobName, containerClient, minutes) {
}
export async function deleteImage(url) {
const containerClient = blobServiceClient.getContainerClient(container);
const containerUrl = containerClient.url + "/";
const blobName = url.replace(containerUrl, "");
console.log(`BLOB NAME = ${blobName}`);
const blob = containerClient.getBlobClient(blobName);
await blob.delete();
if (!url || url === "" || url === "empty") {
return;
} else {
try {
const containerClient = blobServiceClient.getContainerClient(container);
const containerUrl = containerClient.url + "/";
const blobName = url.replace(containerUrl, "");
console.log(`BLOB NAME = ${blobName}`);
const blob = containerClient.getBlobClient(blobName);
await blob.delete();
} catch (error) {
console.log(error);
}
}
}