mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 01:15:49 +10:00
fix: remove presigned branding upload (#3053)
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { APP_DOCUMENT_UPLOAD_SIZE_LIMIT } from '@documenso/lib/constants/app';
|
||||
import {
|
||||
BRANDING_LOGO_ALLOWED_TYPES,
|
||||
BRANDING_LOGO_MAX_SIZE_BYTES,
|
||||
BRANDING_LOGO_MAX_SIZE_MB,
|
||||
} from '@documenso/lib/constants/branding';
|
||||
import { megabytesToBytes } from '@documenso/lib/universal/unit-convertions';
|
||||
import type { ZodRawShape } from 'zod';
|
||||
import z from 'zod';
|
||||
@@ -17,6 +22,21 @@ export const zfdFile = () => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* A `zfd.file()` schema constrained to branding-logo images: size-limited and
|
||||
* restricted to a MIME allowlist. Use for server-side branding logo uploads.
|
||||
*/
|
||||
export const zfdBrandingImageFile = () => {
|
||||
return zfd
|
||||
.file()
|
||||
.refine((file) => file.size <= BRANDING_LOGO_MAX_SIZE_BYTES, {
|
||||
message: `File cannot be larger than ${BRANDING_LOGO_MAX_SIZE_MB}MB`,
|
||||
})
|
||||
.refine((file) => BRANDING_LOGO_ALLOWED_TYPES.includes(file.type), {
|
||||
message: 'File must be a JPG, PNG, or WebP image',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* This helper takes the place of the `z.object` at the root of your schema.
|
||||
* It wraps your schema in a `z.preprocess` that extracts all the data out of a `FormData`
|
||||
|
||||
Reference in New Issue
Block a user