How to use the getExtension function from mime
Find comprehensive JavaScript mime.getExtension code examples handpicked from public code repositorys.
GitHub: broofa/mime
138 139 140 141 142 143 144 145 146 147
```javascript mime.getType('foo/txt'); // ⇨ null mime.getType('bogus_type'); // ⇨ null ``` ### mime.getExtension(type) Get extension for the given mime type. Charset options (often included in Content-Type headers) are ignored. ```javascript
320
0
21
16 17 18 19 20 21 22 23 24 25
let ext = mime.getExtension(file.mimetype); cb(null, short.uuid() + "." + ext); }, }); function fileFilter(req, file, cb) { let ext = mime.getExtension(file.mimetype); if (ext === "png" || ext === "jpeg" || ext === "gif") { cb(null, true); } else { cb(new Error("The file extension is invalid! only png/jpeg are accepted."));
2
0
0
2799 2800 2801 2802 2803 2804 2805 2806 2807 2808
let imageBuffer = decodedImg.data; let type = decodedImg.type; let extension = mime.getExtension(type); var d = new Date(); var time = d.getTime()
0
0
1
512 513 514 515 516 517 518 519 520 521
}; } // HACK // var contentType = mime.lookup(filePath); var contentType = mime.getExtension(filePath); var headers; if (contentType) { headers = {
0
0
2
95 96 97 98 99 100 101 102 103 104
/** * Destructure mimetype and stream creator from provided file and generate * a unique filename for the upload */ const { createReadStream, mimetype } = await file; const filename = uuidv4() + '.' + mime.getExtension(mimetype); // Upload the file to an S3 bucket using the createReadStream const { AWS_S3_BUCKET } = process.env; await s3
0
0
0
1 2 3 4 5 6 7 8 9 10 11
const mime = require("mime"); const basePath = process.cwd(); const layersDir = `${basePath}/layers`; const fileFilter = (req, file, cb, err) => { const type = mime.getExtension(file.mimetype); const conditions = ["png"]; if ( ![...file.originalname].some((e) => [" ", "#"].includes(e)) && conditions.includes(`${type}`)
0
0
0
GitHub: HomieOmie/nodebb-temp
9 10 11 12 13 14 15 16 17 18 19
const image = require('../image'); const meta = require('../meta'); module.exports = function (User) { User.getAllowedProfileImageExtensions = function () { const exts = User.getAllowedImageTypes().map(type => mime.getExtension(type)); if (exts.includes('jpeg')) { exts.push('jpg'); } return exts;
0
0
0
mime.getType is the most popular function in mime (35 examples)