Created
March 27, 2024 21:19
-
-
Save antonkalik/836146bb6298a6e89d2671edfa98570e to your computer and use it in GitHub Desktop.
Generate Attachements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path'; | |
import { Extension } from 'src/@types/enums'; | |
type AttachmentFile = { | |
name: string; | |
ext?: Extension; | |
cid?: string; | |
}; | |
export const generateAttachments = (files: AttachmentFile[] = []) => | |
files.map(file => { | |
const ext = file.ext || Extension.png; | |
const filename = `${file.name}.${ext}`; | |
const imagePath = path.join(__dirname, '..', 'src/assets', filename); | |
return { | |
filename, | |
path: imagePath, | |
cid: file.cid || file.name, | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment