From 2e1999e6f1fbcc2986833e9b230a0df089676593 Mon Sep 17 00:00:00 2001 From: Karl Stoney Date: Fri, 18 Jul 2025 11:32:27 +0100 Subject: [PATCH] Init the storagepath (#4844) --- packages/components/src/storageUtils.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/components/src/storageUtils.ts b/packages/components/src/storageUtils.ts index 54c6b5822..954609a28 100644 --- a/packages/components/src/storageUtils.ts +++ b/packages/components/src/storageUtils.ts @@ -1,19 +1,19 @@ -import path from 'path' -import fs from 'fs' import { DeleteObjectsCommand, GetObjectCommand, + ListObjectsCommand, ListObjectsV2Command, PutObjectCommand, - ListObjectsCommand, S3Client, S3ClientConfig } from '@aws-sdk/client-s3' import { Storage } from '@google-cloud/storage' +import fs from 'fs' import { Readable } from 'node:stream' -import { getUserHome } from './utils' -import { isValidUUID, isPathTraversal } from './validator' +import path from 'path' import sanitize from 'sanitize-filename' +import { getUserHome } from './utils' +import { isPathTraversal, isValidUUID } from './validator' const dirSize = async (directoryPath: string) => { let totalSize = 0 @@ -531,7 +531,13 @@ function getFilePaths(dir: string): FileInfo[] { * Prepare storage path */ export const getStoragePath = (): string => { - return process.env.BLOB_STORAGE_PATH ? path.join(process.env.BLOB_STORAGE_PATH) : path.join(getUserHome(), '.flowise', 'storage') + const storagePath = process.env.BLOB_STORAGE_PATH + ? path.join(process.env.BLOB_STORAGE_PATH) + : path.join(getUserHome(), '.flowise', 'storage') + if (!fs.existsSync(storagePath)) { + fs.mkdirSync(storagePath, { recursive: true }) + } + return storagePath } /**