mirror of
https://github.com/diced/zipline.git
synced 2026-03-12 13:12:50 -07:00
feat: max files per upload (#991)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "public"."Zipline" ADD COLUMN "filesMaxFilesPerUpload" INTEGER NOT NULL DEFAULT 1000;
|
||||
@@ -46,6 +46,7 @@ model Zipline {
|
||||
filesRandomWordsNumAdjectives Int @default(2)
|
||||
filesRandomWordsSeparator String @default("-")
|
||||
filesDefaultCompressionFormat String? @default("jpg")
|
||||
filesMaxFilesPerUpload Int @default(1000)
|
||||
|
||||
urlsRoute String @default("/go")
|
||||
urlsLength Int @default(6)
|
||||
|
||||
@@ -8,7 +8,6 @@ export default function ActionButton({ onClick, Icon }: { onClick: () => void; I
|
||||
<ActionIcon
|
||||
onClick={onClick}
|
||||
variant='filled'
|
||||
color='blue'
|
||||
radius='md'
|
||||
size='xl'
|
||||
className='zip-click-action-button'
|
||||
|
||||
@@ -37,6 +37,7 @@ export default function Files({
|
||||
filesRandomWordsNumAdjectives: number;
|
||||
filesRandomWordsSeparator: string;
|
||||
filesDefaultCompressionFormat: string;
|
||||
filesMaxFilesPerUpload: number;
|
||||
}>({
|
||||
initialValues: {
|
||||
filesRoute: '/u',
|
||||
@@ -52,6 +53,7 @@ export default function Files({
|
||||
filesRandomWordsNumAdjectives: 3,
|
||||
filesRandomWordsSeparator: '-',
|
||||
filesDefaultCompressionFormat: 'jpg',
|
||||
filesMaxFilesPerUpload: 1000,
|
||||
},
|
||||
enhanceGetInputProps: (payload) => ({
|
||||
disabled: data?.tampered?.includes(payload.field) || false,
|
||||
@@ -110,6 +112,7 @@ export default function Files({
|
||||
filesRandomWordsNumAdjectives: data.settings.filesRandomWordsNumAdjectives ?? 3,
|
||||
filesRandomWordsSeparator: data.settings.filesRandomWordsSeparator ?? '-',
|
||||
filesDefaultCompressionFormat: data.settings.filesDefaultCompressionFormat ?? 'jpg',
|
||||
filesMaxFilesPerUpload: data.settings.filesMaxFilesPerUpload ?? 1000,
|
||||
});
|
||||
}, [data]);
|
||||
|
||||
@@ -218,6 +221,13 @@ export default function Files({
|
||||
]}
|
||||
{...form.getInputProps('filesDefaultCompressionFormat')}
|
||||
/>
|
||||
|
||||
<NumberInput
|
||||
label='Max Files Per Upload'
|
||||
description='The maximum number of files allowed per upload. Requires a server restart.'
|
||||
min={1}
|
||||
{...form.getInputProps('filesMaxFilesPerUpload')}
|
||||
/>
|
||||
</SimpleGrid>
|
||||
|
||||
<Button type='submit' mt='md' loading={isLoading} leftSection={<IconDeviceFloppy size='1rem' />}>
|
||||
|
||||
@@ -32,6 +32,7 @@ export const DATABASE_TO_PROP = {
|
||||
filesRandomWordsNumAdjectives: 'files.randomWordsNumAdjectives',
|
||||
filesRandomWordsSeparator: 'files.randomWordsSeparator',
|
||||
filesDefaultCompressionFormat: 'files.defaultCompressionFormat',
|
||||
filesMaxFilesPerUpload: 'files.maxFilesPerUpload',
|
||||
|
||||
urlsRoute: 'urls.route',
|
||||
urlsLength: 'urls.length',
|
||||
|
||||
@@ -65,6 +65,7 @@ export const ENVS = [
|
||||
env('files.randomWordsNumAdjectives', 'FILES_RANDOM_WORDS_NUM_ADJECTIVES', 'number', true),
|
||||
env('files.randomWordsSeparator', 'FILES_RANDOM_WORDS_SEPARATOR', 'string', true),
|
||||
env('files.defaultCompressionFormat', 'FILES_DEFAULT_COMPRESSION_FORMAT', 'string', true),
|
||||
env('files.maxFilesPerUpload', 'FILES_MAX_FILES_PER_UPLOAD', 'number', true),
|
||||
|
||||
env('urls.route', 'URLS_ROUTE', 'string', true),
|
||||
env('urls.length', 'URLS_LENGTH', 'number', true),
|
||||
|
||||
@@ -48,6 +48,7 @@ export const rawConfig: any = {
|
||||
randomWordsNumAdjectives: undefined,
|
||||
randomWordsSeparator: undefined,
|
||||
defaultCompressionFormat: undefined,
|
||||
maxFilesPerUpload: undefined,
|
||||
},
|
||||
urls: {
|
||||
route: undefined,
|
||||
|
||||
@@ -144,6 +144,7 @@ export const schema = z.object({
|
||||
.enum(COMPRESS_TYPES)
|
||||
.default('jpg')
|
||||
.refine((v) => checkOutput(v), 'System does not support outputting this image format.'),
|
||||
maxFilesPerUpload: z.number().max(2147483647).min(1).default(1000),
|
||||
}),
|
||||
urls: z.object({
|
||||
route: z.string().startsWith('/').min(1).trim().toLowerCase().default('/go'),
|
||||
|
||||
@@ -126,6 +126,7 @@ async function main() {
|
||||
await server.register(fastifyMultipart, {
|
||||
limits: {
|
||||
fileSize: bytes(config.files.maxFileSize),
|
||||
parts: config.files.maxFilesPerUpload,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ export default typedPlugin(
|
||||
filesDefaultCompressionFormat: z
|
||||
.enum(COMPRESS_TYPES)
|
||||
.refine((v) => checkOutput(v), 'System does not support outputting this image format.'),
|
||||
filesMaxFilesPerUpload: z.number().min(1).max(2147483647),
|
||||
|
||||
urlsRoute: z
|
||||
.string()
|
||||
|
||||
Reference in New Issue
Block a user