Skip to content

Commit 7617d4d

Browse files
formatting
1 parent 1a6d855 commit 7617d4d

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

backend/controllers/fileUploadController.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ export const getPresignedUploadUrl = async (req: AuthenticatedRequest, res: Resp
2424
if (!fileType || typeof fileType !== 'string') {
2525
return res.status(400).json({ error: 'Valid file type is required' });
2626
}
27-
const allowedExtensions = ['.pdf', '.doc', '.docx', '.jpg', '.jpeg', '.png', '.gif', '.txt', '.webp'];
27+
const allowedExtensions = [
28+
'.pdf',
29+
'.doc',
30+
'.docx',
31+
'.jpg',
32+
'.jpeg',
33+
'.png',
34+
'.gif',
35+
'.txt',
36+
'.webp',
37+
];
2838
const fileExt = fileName.substring(fileName.lastIndexOf('.')).toLowerCase();
2939
if (!allowedExtensions.includes(fileExt)) {
3040
return res.status(400).json({ error: 'File type not allowed' });
@@ -55,7 +65,16 @@ export const getPresignedUploadUrl = async (req: AuthenticatedRequest, res: Resp
5565
const sanitizedFileName = fileName.replace(/[^a-zA-Z0-9.-]/g, '_');
5666
let key: string;
5767
if (folder && typeof folder === 'string') {
58-
const validFolders = ['announcements', 'blogs', 'alerts', 'pages/homepage', 'pages/about', 'pages/getinvolved', 'pages/directory', 'emails'];
68+
const validFolders = [
69+
'announcements',
70+
'blogs',
71+
'alerts',
72+
'pages/homepage',
73+
'pages/about',
74+
'pages/getinvolved',
75+
'pages/directory',
76+
'emails',
77+
];
5978
const isValidFolder = validFolders.some(f => folder === f || folder.startsWith(f + '/'));
6079

6180
if (!isValidFolder && !folder.startsWith('pages/')) {

frontend/src/components/FileUpload.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ interface FileUploadProps {
1010
resourceId?: string;
1111
}
1212

13-
const FileUpload = ({ attachmentUrls, onFilesChange, maxFiles, folder, resourceId }: FileUploadProps) => {
13+
const FileUpload = ({
14+
attachmentUrls,
15+
onFilesChange,
16+
maxFiles,
17+
folder,
18+
resourceId,
19+
}: FileUploadProps) => {
1420
const { getToken } = useAuth();
1521
const [uploading, setUploading] = useState(false);
1622
const [uploadError, setUploadError] = useState<string | null>(null);

0 commit comments

Comments
 (0)