Migrate to a monorepo structure (#2909)
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
export const downloadFile = (fullPath: string, fileName: string) => {
|
||||
fetch(process.env.REACT_APP_SERVER_BASE_URL + '/files/' + fullPath)
|
||||
.then((resp) =>
|
||||
resp.status === 200
|
||||
? resp.blob()
|
||||
: Promise.reject('Failed downloading file'),
|
||||
)
|
||||
.then((blob) => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = url;
|
||||
a.download = fileName;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
});
|
||||
};
|
||||
@ -0,0 +1,67 @@
|
||||
import { AttachmentType } from '@/activities/files/types/Attachment';
|
||||
|
||||
const FileExtensionMapping: { [key: string]: AttachmentType } = {
|
||||
doc: 'TextDocument',
|
||||
docm: 'TextDocument',
|
||||
docx: 'TextDocument',
|
||||
dot: 'TextDocument',
|
||||
dotx: 'TextDocument',
|
||||
odt: 'TextDocument',
|
||||
pdf: 'TextDocument',
|
||||
txt: 'TextDocument',
|
||||
rtf: 'TextDocument',
|
||||
ps: 'TextDocument',
|
||||
tex: 'TextDocument',
|
||||
pages: 'TextDocument',
|
||||
xls: 'Spreadsheet',
|
||||
xlsb: 'Spreadsheet',
|
||||
xlsm: 'Spreadsheet',
|
||||
xlsx: 'Spreadsheet',
|
||||
xltx: 'Spreadsheet',
|
||||
csv: 'Spreadsheet',
|
||||
tsv: 'Spreadsheet',
|
||||
ods: 'Spreadsheet',
|
||||
numbers: 'Spreadsheet',
|
||||
ppt: 'Presentation',
|
||||
pptx: 'Presentation',
|
||||
potx: 'Presentation',
|
||||
odp: 'Presentation',
|
||||
html: 'Presentation',
|
||||
key: 'Presentation',
|
||||
kth: 'Presentation',
|
||||
png: 'Image',
|
||||
jpg: 'Image',
|
||||
jpeg: 'Image',
|
||||
svg: 'Image',
|
||||
gif: 'Image',
|
||||
webp: 'Image',
|
||||
heif: 'Image',
|
||||
tif: 'Image',
|
||||
tiff: 'Image',
|
||||
bmp: 'Image',
|
||||
ico: 'Image',
|
||||
mp4: 'Video',
|
||||
avi: 'Video',
|
||||
mov: 'Video',
|
||||
wmv: 'Video',
|
||||
mpg: 'Video',
|
||||
mpeg: 'Video',
|
||||
mp3: 'Audio',
|
||||
wav: 'Audio',
|
||||
ogg: 'Audio',
|
||||
wma: 'Audio',
|
||||
zip: 'Archive',
|
||||
tar: 'Archive',
|
||||
iso: 'Archive',
|
||||
gz: 'Archive',
|
||||
rar: 'Archive',
|
||||
'7z': 'Archive',
|
||||
};
|
||||
|
||||
export const getFileType = (fileName: string): AttachmentType => {
|
||||
const fileExtension = fileName.split('.').at(-1);
|
||||
if (!fileExtension) {
|
||||
return 'Other';
|
||||
}
|
||||
return FileExtensionMapping[fileExtension.toLowerCase()] ?? 'Other';
|
||||
};
|
||||
Reference in New Issue
Block a user