diff --git a/packages/service/common/s3/validation/upload.ts b/packages/service/common/s3/validation/upload.ts index fbbf49785e..c863f42668 100644 --- a/packages/service/common/s3/validation/upload.ts +++ b/packages/service/common/s3/validation/upload.ts @@ -4,6 +4,7 @@ import path from 'node:path'; import type { UploadConstraints } from '../contracts/type'; import { DEFAULT_CONTENT_TYPE, resolveMimeType } from '../utils/mime'; import { normalizeAllowedExtensions, normalizeFileExtension } from '../utils/uploadConstraints'; +import { env } from '../../../env'; const defaultInspectBytes = 8192; const officeZipInspectBytes = 64 * 1024; @@ -171,6 +172,14 @@ export async function validateUploadFile({ extension, uploadConstraints }); + + if (env.SKIP_FILE_TYPE_CHECK) { + return { + filename: normalizedFileName, + contentType: expectedMime + }; + } + const detected = await fileTypeFromBuffer(buffer).catch((error) => { if (error?.name === 'EndOfStreamError' || error?.message === 'End-Of-Stream') { return undefined; diff --git a/packages/service/env.ts b/packages/service/env.ts index e584c7ea55..6e5384fe36 100644 --- a/packages/service/env.ts +++ b/packages/service/env.ts @@ -1,9 +1,10 @@ import { createEnv } from '@t3-oss/env-core'; import z from 'zod'; +const truthyBoolStrs = ['true', '1', 'yes', 'y']; const BoolSchema = z .string() - .transform((val) => val === 'true') + .transform((val) => truthyBoolStrs.includes(val.toLowerCase())) .pipe(z.boolean()); const NumSchema = z.coerce.number(); @@ -17,6 +18,7 @@ const StorageCosProtocolSchema = z.enum(['https:', 'http:']); export const env = createEnv({ server: { FILE_TOKEN_KEY: z.string().min(6, 'FILE_TOKEN_KEY must be at least 6 characters'), + // ===== Agent sandbox ===== AGENT_SANDBOX_PROVIDER: z.enum(['sealosdevbox', 'opensandbox', 'e2b']).optional(), AGENT_SANDBOX_E2B_API_KEY: z.string().optional(), @@ -124,7 +126,9 @@ export const env = createEnv({ SHOW_SKILL: BoolSchema.default(false), // Agent engine selection: 'default' uses the built-in Plan+Step engine, 'pi' uses pi-agent-core - AGENT_ENGINE: z.enum(['default', 'pi']).default('default') + AGENT_ENGINE: z.enum(['default', 'pi']).default('default'), + + SKIP_FILE_TYPE_CHECK: BoolSchema.default(false) }, emptyStringAsUndefined: true, runtimeEnv: process.env,