Skip to content

Commit

Permalink
#756 Get extension with mime-types library
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvansson committed Jul 25, 2020
1 parent d59fb21 commit c7868bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"keycode": "^2.2.0",
"lodash": "^4.17.16",
"matx": "1.0.0",
"mime-types": "^2.1.27",
"moment": "2.27.0",
"opencollective": "^1.0.3",
"pdfmake": "^0.1.66",
Expand Down
8 changes: 4 additions & 4 deletions src/components/Settings/Export/Export.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from '../../../cordova-util';
import { getStore } from '../../../store';
import * as _ from 'lodash';
import mime from 'mime-types';

pdfMake.vfs = pdfFonts.pdfMake.vfs;

Expand Down Expand Up @@ -132,15 +133,14 @@ async function boardToOBF(boardsMap, board = {}, intl, { embed = false }) {
: tile.image;
let imageResponse = null;
let path = '';
let contentType = '';
let fetchedImageID = `custom/${board.name ||
board.nameKey}/${tile.label || tile.labelKey || tile.id}`;

if (image.startsWith('data:')) {
imageResponse = getBase64Image(image);
contentType = imageResponse['content_type'];
const defaultExtension =
contentType.indexOf('/') >= 0 ? contentType.split('/')[1] : '';
const defaultExtension = mime.extension(
imageResponse['content_type']
);
fetchedImageID = defaultExtension.length
? `${fetchedImageID}.${defaultExtension}`
: fetchedImageID;
Expand Down

0 comments on commit c7868bc

Please sign in to comment.