Skip to content

Commit 2e1999e

Browse files
authored
Init the storagepath (#4844)
1 parent 5e5b2a1 commit 2e1999e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/components/src/storageUtils.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import path from 'path'
2-
import fs from 'fs'
31
import {
42
DeleteObjectsCommand,
53
GetObjectCommand,
4+
ListObjectsCommand,
65
ListObjectsV2Command,
76
PutObjectCommand,
8-
ListObjectsCommand,
97
S3Client,
108
S3ClientConfig
119
} from '@aws-sdk/client-s3'
1210
import { Storage } from '@google-cloud/storage'
11+
import fs from 'fs'
1312
import { Readable } from 'node:stream'
14-
import { getUserHome } from './utils'
15-
import { isValidUUID, isPathTraversal } from './validator'
13+
import path from 'path'
1614
import sanitize from 'sanitize-filename'
15+
import { getUserHome } from './utils'
16+
import { isPathTraversal, isValidUUID } from './validator'
1717

1818
const dirSize = async (directoryPath: string) => {
1919
let totalSize = 0
@@ -531,7 +531,13 @@ function getFilePaths(dir: string): FileInfo[] {
531531
* Prepare storage path
532532
*/
533533
export const getStoragePath = (): string => {
534-
return process.env.BLOB_STORAGE_PATH ? path.join(process.env.BLOB_STORAGE_PATH) : path.join(getUserHome(), '.flowise', 'storage')
534+
const storagePath = process.env.BLOB_STORAGE_PATH
535+
? path.join(process.env.BLOB_STORAGE_PATH)
536+
: path.join(getUserHome(), '.flowise', 'storage')
537+
if (!fs.existsSync(storagePath)) {
538+
fs.mkdirSync(storagePath, { recursive: true })
539+
}
540+
return storagePath
535541
}
536542

537543
/**

0 commit comments

Comments
 (0)