aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Hu <51237606+jameshu111@users.noreply.github.com>2023-07-06 11:22:44 -0400
committerJames Hu <51237606+jameshu111@users.noreply.github.com>2023-07-06 11:22:44 -0400
commit5a1c452941032c8a5c468e54674450f452d8bda9 (patch)
tree09b54a85705024083d379369156c89dbb519c538 /src
parent5379662bdc9279e43d35166ce8bafe042d0d7fb6 (diff)
flag with comments
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts3
-rw-r--r--src/server/DashUploadUtils.ts24
2 files changed, 20 insertions, 7 deletions
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<Upload.FileResponse> {
+ 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<Stream>, 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;
}