Init the storagepath (#4844)

This commit is contained in:
Karl Stoney 2025-07-18 11:32:27 +01:00 committed by GitHub
parent 5e5b2a18e2
commit 2e1999e6f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 6 deletions

View File

@ -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
}
/**