@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
15 lines (14 loc) • 512 B
JavaScript
import mimeTypes from "mime-types";
/**
* Validates and returns the MIME type for a given filename
* @param filename - The name of the file (e.g., 'image.png', 'data.json')
* @returns The MIME type string
* @throws Error if the file type is not supported
*/
export function getMimeType(filename) {
const mimeType = mimeTypes.lookup(filename);
if (!mimeType) {
throw new Error(`Unsupported file type: ${filename}. Please ensure the file has a valid extension.`);
}
return mimeType;
}