Init the storagepath (#4844)
This commit is contained in:
parent
5e5b2a18e2
commit
2e1999e6f1
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue