Component

Add:
- upload button : masih percobaan

Utils:
Add:
- file validasi untuk upload file

Pakage
Add:
- expo-document-picker
- expo-file-system

## No Issue
This commit is contained in:
2025-07-30 10:39:54 +08:00
parent 8a514d2670
commit 927db87749
5 changed files with 172 additions and 6 deletions

34
utils/fileValidation.ts Normal file
View File

@@ -0,0 +1,34 @@
// utils/fileValidation.ts
const ALLOWED_TYPES: Record<string, string[]> = {
image: ["jpeg", "jpg", "png"],
document: ["pdf", "png"],
pdf: ["pdf"],
png: ["png"],
};
export const isValidFileType = (
fileName: string,
allowedExtensions: string[]
): boolean => {
const extension = fileName.split(".").pop()?.toLowerCase();
return !!extension && allowedExtensions.includes(extension);
};
// Helper: Dapatkan MIME type berdasarkan ekstensi (opsional)
export const getMimeType = (fileName: string): string => {
const ext = fileName.split(".").pop()?.toLowerCase();
switch (ext) {
case "jpg":
return "image/jpg";
case "jpeg":
return "image/jpeg";
case "png":
return "image/png";
case "pdf":
return "application/pdf";
default:
return "application/octet-stream";
}
};
export default ALLOWED_TYPES;