mirror of
https://github.com/diced/zipline.git
synced 2025-12-12 07:40:45 -08:00
fix: defaultExpiration as a string now
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Zipline" ALTER COLUMN "filesDefaultExpiration" SET DATA TYPE TEXT;
|
||||
@@ -34,7 +34,7 @@ model Zipline {
|
||||
filesDefaultFormat String @default("random")
|
||||
filesDisabledExtensions String[]
|
||||
filesMaxFileSize Int @default(104857600)
|
||||
filesDefaultExpiration Int?
|
||||
filesDefaultExpiration String?
|
||||
filesAssumeMimetypes Boolean @default(false)
|
||||
filesDefaultDateFormat String @default("YYYY-MM-DD_HH:mm:ss")
|
||||
filesRemoveGpsMetadata Boolean @default(false)
|
||||
|
||||
@@ -84,7 +84,7 @@ export default function ServerSettingsFiles({
|
||||
filesDefaultFormat: data?.filesDefaultFormat ?? 'random',
|
||||
filesDisabledExtensions: data?.filesDisabledExtensions.join(', ') ?? '',
|
||||
filesMaxFileSize: bytes(data?.filesMaxFileSize ?? 104857600),
|
||||
filesDefaultExpiration: data?.filesDefaultExpiration ? ms(data.filesDefaultExpiration) : '',
|
||||
filesDefaultExpiration: data?.filesDefaultExpiration ?? '',
|
||||
filesAssumeMimetypes: data?.filesAssumeMimetypes ?? false,
|
||||
filesDefaultDateFormat: data?.filesDefaultDateFormat ?? 'YYYY-MM-DD_HH:mm:ss',
|
||||
filesRemoveGpsMetadata: data?.filesRemoveGpsMetadata ?? false,
|
||||
|
||||
@@ -92,7 +92,7 @@ export const schema = z.object({
|
||||
defaultFormat: z.enum(['random', 'date', 'uuid', 'name', 'gfycat']).default('random'),
|
||||
disabledExtensions: z.array(z.string()).default([]),
|
||||
maxFileSize: z.number().default(bytes('100mb')),
|
||||
defaultExpiration: z.number().nullable().default(null),
|
||||
defaultExpiration: z.string().nullable().default(null),
|
||||
assumeMimetypes: z.boolean().default(false),
|
||||
defaultDateFormat: z.string().default('YYYY-MM-DD_HH:mm:ss'),
|
||||
removeGpsMetadata: z.boolean().default(false),
|
||||
|
||||
@@ -147,7 +147,7 @@ export function parseHeaders(headers: UploadHeaders, fileConfig: Config['files']
|
||||
response.deletesAt = expiresAt;
|
||||
} else {
|
||||
if (fileConfig.defaultExpiration) {
|
||||
const expiresAt = new Date(Date.now() + fileConfig.defaultExpiration);
|
||||
const expiresAt = new Date(Date.now() + ms(fileConfig.defaultExpiration));
|
||||
response.deletesAt = expiresAt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ const zMs = z
|
||||
.transform((value) => (typeof value === 'string' ? ms(value) : value))
|
||||
.refine((value) => value > 0, 'Value must be greater than 0');
|
||||
|
||||
const zMsString = z.string().refine((value) => ms(value) > 0, 'Value must be greater than 0');
|
||||
|
||||
const zBytes = z
|
||||
.union([z.number().min(1), z.string()])
|
||||
.transform((value) => (typeof value === 'string' ? bytes(value) : value))
|
||||
@@ -123,7 +125,7 @@ export default fastifyPlugin(
|
||||
),
|
||||
filesMaxFileSize: zBytes,
|
||||
|
||||
filesDefaultExpiration: zMs,
|
||||
filesDefaultExpiration: zMsString.nullable(),
|
||||
filesAssumeMimetypes: z.boolean(),
|
||||
filesDefaultDateFormat: z.string(),
|
||||
filesRemoveGpsMetadata: z.boolean(),
|
||||
|
||||
Reference in New Issue
Block a user