From 5f44a6cf1f16023a4c39872f2ccfc129c65ea812 Mon Sep 17 00:00:00 2001 From: James Hu <51237606+jameshu111@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:37:11 -0400 Subject: temp working version --- package.json | 1 + 1 file changed, 1 insertion(+) (limited to 'package.json') diff --git a/package.json b/package.json index 6cd271c96..3a3d17517 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,7 @@ "webpack-hot-middleware": "^2.25.1" }, "dependencies": { + "@azure/storage-blob": "^12.14.0", "@emotion/react": "^11.11.0", "@emotion/styled": "^11.11.0", "@ffmpeg/core": "0.10.0", -- cgit v1.2.3-70-g09d2 From 5a1c452941032c8a5c468e54674450f452d8bda9 Mon Sep 17 00:00:00 2001 From: James Hu <51237606+jameshu111@users.noreply.github.com> Date: Thu, 6 Jul 2023 11:22:44 -0400 Subject: flag with comments --- package.json | 2 +- src/client/documents/Documents.ts | 3 ++- src/server/DashUploadUtils.ts | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) (limited to 'package.json') diff --git a/package.json b/package.json index 3a3d17517..2b37d5171 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "start-release": "cross-env RELEASE=true NODE_OPTIONS=--max_old_space_size=4096 ts-node-dev -- src/server/index.ts", "start": "cross-env NODE_OPTIONS=--max_old_space_size=4096 ts-node-dev --debug --transpile-only -- src/server/index.ts", "oldstart": "cross-env NODE_OPTIONS=--max_old_space_size=4096 ts-node-dev --debug -- src/server/index.ts", - "debug": "cross-env NODE_OPTIONS=--max_old_space_size=8192 ts-node-dev --transpile-only --inspect -- src/server/index.ts", + "debug": "cross-env USE_AZURE=true NODE_OPTIONS=--max_old_space_size=8192 ts-node-dev --transpile-only --inspect -- src/server/index.ts", "monitor": "cross-env MONITORED=true NODE_OPTIONS=--max_old_space_size=4096 ts-node src/server/index.ts", "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 webpack --env production", "test": "mocha -r ts-node/register test/**/*.ts", diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 93043e517..43c9d2e7a 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -1737,7 +1737,8 @@ export namespace DocUtils { } const full = { ...options, _width: 400, title: name }; // const pathname = Utils.prepend(result.accessPaths.agnostic.client); - const pathname = result.accessPaths.azure.client; + const pathname = result.accessPaths.agnostic.client; + // const pathname = result.accessPaths.azure.client; const doc = await DocUtils.DocumentFromType(type, pathname, full, overwriteDoc); if (doc) { const proto = Doc.GetProto(doc); diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index 7abefed8a..74c4786b6 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -43,6 +43,10 @@ function isLocal() { return /Dash-Web[0-9]*[\\\/]src[\\\/]server[\\\/]public[\\\/](.*)/; } +function usingAzure(){ + return process.env.USE_AZURE === 'true'; +} + export namespace DashUploadUtils { export interface Size { width: number; @@ -183,6 +187,8 @@ export namespace DashUploadUtils { } export async function upload(file: File, overwriteGuid?: string): Promise { + const isAzureOn = usingAzure(); + console.log("Azure usage: ", isAzureOn); const { type, path, name } = file; const types = type?.split('/') ?? []; uploadProgress.set(overwriteGuid ?? name, 'uploading'); // If the client sent a guid it uses to track upload progress, use that guid. Otherwise, use the file's name. @@ -486,11 +492,15 @@ export namespace DashUploadUtils { const { images } = Directory; const information: Upload.ImageInformation = { accessPaths: { - agnostic: getAccessPaths(images, resolved), - azure: { + // agnostic: getAccessPaths(images, resolved), + // azure: { + // client: `https://dashblobstore.blob.core.windows.net/dashmedia/${filename}`, + // server: `https://dashblobstore.blob.core.windows.net/dashmedia/${filename}` + // } + agnostic: usingAzure() ? { client: `https://dashblobstore.blob.core.windows.net/dashmedia/${filename}`, server: `https://dashblobstore.blob.core.windows.net/dashmedia/${filename}` - } + } : getAccessPaths(images, resolved) }, ...metadata, }; @@ -540,7 +550,7 @@ export namespace DashUploadUtils { }; export async function outputResizedImages(streamProvider: () => Stream | Promise, outputFileName: string, outputDirectory: string, originalFilename?: string, contentType?: string) { - console.log("resized original filename: ", originalFilename); + const start = Date.now(); const writtenFiles: { [suffix: string]: string } = {}; for (const { resizer, suffix } of resizers(path.extname(outputFileName))) { const outputPath = path.resolve(outputDirectory, (writtenFiles[suffix] = InjectSize(outputFileName, suffix))); @@ -552,13 +562,15 @@ export namespace DashUploadUtils { if (resizer) { readStream = readStream.pipe(resizer.withMetadata()); } - if(originalFilename && contentType) { - AzureManager.UploadBlobStream(readStream as Readable, InjectSize(originalFilename, suffix), contentType); + if(contentType && usingAzure()) { + // AzureManager.UploadBlobStream(readStream as Readable, InjectSize(originalFilename, suffix), contentType); AzureManager.UploadBlobStream(readStream as Readable, InjectSize(outputFileName, suffix), contentType); } readStream.pipe(createWriteStream(outputPath)).on('close', resolve).on('error', reject); }); } + const end = Date.now(); + console.log(`Time taken: ${end - start}ms`); return writtenFiles; } -- cgit v1.2.3-70-g09d2 From 021242ed45ef711d9e1a9bf29095e4cc529a2545 Mon Sep 17 00:00:00 2001 From: jameshu111 <51237606+jameshu111@users.noreply.github.com> Date: Thu, 13 Jul 2023 10:48:24 -0400 Subject: disable azure --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'package.json') diff --git a/package.json b/package.json index 2b37d5171..05717031d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "start-release": "cross-env RELEASE=true NODE_OPTIONS=--max_old_space_size=4096 ts-node-dev -- src/server/index.ts", "start": "cross-env NODE_OPTIONS=--max_old_space_size=4096 ts-node-dev --debug --transpile-only -- src/server/index.ts", "oldstart": "cross-env NODE_OPTIONS=--max_old_space_size=4096 ts-node-dev --debug -- src/server/index.ts", - "debug": "cross-env USE_AZURE=true NODE_OPTIONS=--max_old_space_size=8192 ts-node-dev --transpile-only --inspect -- src/server/index.ts", + "debug": "cross-env USE_AZURE=false NODE_OPTIONS=--max_old_space_size=8192 ts-node-dev --transpile-only --inspect -- src/server/index.ts", "monitor": "cross-env MONITORED=true NODE_OPTIONS=--max_old_space_size=4096 ts-node src/server/index.ts", "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 webpack --env production", "test": "mocha -r ts-node/register test/**/*.ts", -- cgit v1.2.3-70-g09d2