mirror of
				https://github.com/kyantech/Palmr.git
				synced 2025-11-04 05:53:23 +00:00 
			
		
		
		
	I implemented a new API Endpoint /files/check that is queried before trying to upload the file to the MinIO backend. This prevents the current issue where files exceeding the maximum file size would be uploaded to the storage backend but then fail to get registered, resulting in "dead" data invisible in the frontend but stored in the backend. Additionally I added new toast notifications for the following errors that can happen while checking if the file is valid: - filesizeExceeded: Displays a toast that the file is too large and shows the current MAX_FILESIZE - insufficientStorage: Displays a toast with the error that not enough storage is available together with the currently available storage - unauthorized: Displays a toast saying that the token is invalid
		
			
				
	
	
		
			34 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { z } from "zod";
 | 
						|
 | 
						|
export const RegisterFileSchema = z.object({
 | 
						|
  name: z.string().min(1, "O nome do arquivo é obrigatório"),
 | 
						|
  description: z.string().optional(),
 | 
						|
  extension: z.string().min(1, "A extensão é obrigatória"),
 | 
						|
  size: z.number({
 | 
						|
    required_error: "O tamanho é obrigatório",
 | 
						|
    invalid_type_error: "O tamanho deve ser um número",
 | 
						|
  }),
 | 
						|
  objectName: z.string().min(1, "O objectName é obrigatório"),
 | 
						|
});
 | 
						|
 | 
						|
export const CheckFileSchema = z.object({
 | 
						|
  name: z.string().min(1, "O nome do arquivo é obrigatório"),
 | 
						|
  description: z.string().optional(),
 | 
						|
  extension: z.string().min(1, "A extensão é obrigatória"),
 | 
						|
  size: z.number({
 | 
						|
    required_error: "O tamanho é obrigatório",
 | 
						|
    invalid_type_error: "O tamanho deve ser um número",
 | 
						|
  }),
 | 
						|
  objectName: z.string().min(1, "O objectName é obrigatório"),
 | 
						|
});
 | 
						|
 | 
						|
export type RegisterFileInput = z.infer<typeof RegisterFileSchema>;
 | 
						|
export type CheckFileInput = z.infer<typeof CheckFileSchema>;
 | 
						|
 | 
						|
export const UpdateFileSchema = z.object({
 | 
						|
  name: z.string().optional().describe("The file name"),
 | 
						|
  description: z.string().optional().nullable().describe("The file description"),
 | 
						|
});
 | 
						|
 | 
						|
export type UpdateFileInput = z.infer<typeof UpdateFileSchema>;
 |