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 { import {
DeleteObjectsCommand, DeleteObjectsCommand,
GetObjectCommand, GetObjectCommand,
ListObjectsCommand,
ListObjectsV2Command, ListObjectsV2Command,
PutObjectCommand, PutObjectCommand,
ListObjectsCommand,
S3Client, S3Client,
S3ClientConfig S3ClientConfig
} from '@aws-sdk/client-s3' } from '@aws-sdk/client-s3'
import { Storage } from '@google-cloud/storage' import { Storage } from '@google-cloud/storage'
import fs from 'fs'
import { Readable } from 'node:stream' import { Readable } from 'node:stream'
import { getUserHome } from './utils' import path from 'path'
import { isValidUUID, isPathTraversal } from './validator'
import sanitize from 'sanitize-filename' import sanitize from 'sanitize-filename'
import { getUserHome } from './utils'
import { isPathTraversal, isValidUUID } from './validator'
const dirSize = async (directoryPath: string) => { const dirSize = async (directoryPath: string) => {
let totalSize = 0 let totalSize = 0
@ -531,7 +531,13 @@ function getFilePaths(dir: string): FileInfo[] {
* Prepare storage path * Prepare storage path
*/ */
export const getStoragePath = (): string => { 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
} }
/** /**