diff options
Diffstat (limited to 'src/server/ApiManagers/AzureManager.ts')
-rw-r--r-- | src/server/ApiManagers/AzureManager.ts | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/server/ApiManagers/AzureManager.ts b/src/server/ApiManagers/AzureManager.ts index e105f5d80..12bb98ad0 100644 --- a/src/server/ApiManagers/AzureManager.ts +++ b/src/server/ApiManagers/AzureManager.ts @@ -1,9 +1,7 @@ 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 = "DefaultEndpointsProtocol=https;AccountName=dashblobstore;AccountKey=3i+E5XkCz3TJ0m5QOatiEnbRACz9V1qCW72L6ldiYGH1tLdfJWa2eQoRfYmPA68lx1a6YAcfYJfWHadIxQvhGQ==;EndpointSuffix=core.windows.net"; +const AZURE_STORAGE_CONNECTION_STRING = process.env.AZURE_STORAGE_CONNECTION_STRING; export class AzureManager { private _containerClient: ContainerClient; @@ -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 +} |