aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/AzureManager.ts
diff options
context:
space:
mode:
authorJames Hu <51237606+jameshu111@users.noreply.github.com>2023-07-11 11:32:43 -0400
committerJames Hu <51237606+jameshu111@users.noreply.github.com>2023-07-11 11:32:43 -0400
commita5194a874236eafc42a61c96d5b22c8622170149 (patch)
treecb5ca3325cfd88f865672cacad795fa73328607a /src/server/ApiManagers/AzureManager.ts
parent71a5c4a6ff126a256b4053d539b6099e5a429bbc (diff)
clean up
Diffstat (limited to 'src/server/ApiManagers/AzureManager.ts')
-rw-r--r--src/server/ApiManagers/AzureManager.ts11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/server/ApiManagers/AzureManager.ts b/src/server/ApiManagers/AzureManager.ts
index 7e319f123..12bb98ad0 100644
--- a/src/server/ApiManagers/AzureManager.ts
+++ b/src/server/ApiManagers/AzureManager.ts
@@ -1,8 +1,6 @@
import { ContainerClient, BlobServiceClient } from "@azure/storage-blob";
-// import * as dotenv from 'dotenv';
import * as fs from "fs";
import { Readable, Stream } from "stream";
-// dotenv.config();
const AZURE_STORAGE_CONNECTION_STRING = process.env.AZURE_STORAGE_CONNECTION_STRING;
export class AzureManager {
@@ -15,9 +13,8 @@ export class AzureManager {
constructor() {
if (!AZURE_STORAGE_CONNECTION_STRING) {
- throw Error("Azure Storage Connection String Not Found");
+ throw new Error("Azure Storage Connection String Not Found");
}
- // this._blobServiceClient = BlobServiceClient.fromConnectionString(process.env.AZURE_STORAGE_CONNECTION_STRING);
this._blobServiceClient = BlobServiceClient.fromConnectionString(AZURE_STORAGE_CONNECTION_STRING);
this._containerClient = this.BlobServiceClient.getContainerClient(AzureManager.CONTAINER_NAME);
}
@@ -35,7 +32,6 @@ export class AzureManager {
}
public static UploadBlob(filename: string, filepath: string, filetype: string) {
- console.log("Upload Blob File");
const blockBlobClient = this.Instance.ContainerClient.getBlockBlobClient(filename);
const blobOptions = { blobHTTPHeaders: { blobContentType: filetype }};
const stream = fs.createReadStream(filepath);
@@ -43,20 +39,17 @@ export class AzureManager {
}
public static UploadBlobStream(stream: Readable, filename: string, filetype: string) {
- console.log("Upload Blob Stream: %s, %s", filename, filetype);
const blockBlobClient = this.Instance.ContainerClient.getBlockBlobClient(filename);
const blobOptions = { blobHTTPHeaders: { blobContentType: filetype }};
return blockBlobClient.uploadStream(stream, undefined, undefined, blobOptions);
}
public static DeleteBlob(filename: string) {
- console.log("Delete Blob from filename");
const blockBlobClient = this.Instance.ContainerClient.getBlockBlobClient(filename);
return blockBlobClient.deleteIfExists();
}
public static async GetBlobs() {
- console.log("Get Blobs");
const foundBlobs = [];
for await (const blob of this.Instance.ContainerClient.listBlobsFlat()) {
console.log(`${blob.name}`);
@@ -71,4 +64,4 @@ export class AzureManager {
return foundBlobs;
}
-} \ No newline at end of file
+}