diff --git a/package.json b/package.json index 50e50cdff2f3a3fb1264ff6e49ddc30a6cfbc0e1..90bbef5bad7d4efc81f5dac4a877a0ded571205d 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "body-parser": "^1.18.2", "brolog": "^1.2.8", "hot-import": "^0.1.21", + "mime": "^2.0.3", "puppeteer": "^0.11.0", "raven": "^2.2.1", "request": "^2.83.0", diff --git a/src/misc.ts b/src/misc.ts index 099ad2d50aedba7dd5f29ff5d6cf01fb07e32061..af7f5e349835f7107d11b1229e47e71189389fee 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -274,26 +274,26 @@ export class Misc { } } - public static mime(ext): string { - switch (ext) { - case 'pdf': - return 'application/pdf' - case 'bmp': - return 'image/bmp' - case 'jpeg': - return 'image/jpeg' - case 'jpg': - return 'image/jpeg' - case 'png': - return 'image/png' - case 'gif': - return 'image/gif' - case 'mp4': - return 'video/mp4' - default: - return 'application/octet-stream' - } - } + // public static mime(ext): string { + // switch (ext) { + // case 'pdf': + // return 'application/pdf' + // case 'bmp': + // return 'image/bmp' + // case 'jpeg': + // return 'image/jpeg' + // case 'jpg': + // return 'image/jpeg' + // case 'png': + // return 'image/png' + // case 'gif': + // return 'image/gif' + // case 'mp4': + // return 'video/mp4' + // default: + // return 'application/octet-stream' + // } + // } } export default Misc diff --git a/src/puppet-web/puppet-web.ts b/src/puppet-web/puppet-web.ts index 1257e90d52f9db7f68726bbeb9dc3ef4d5f54719..de4964bc0f3a3d4a60f6c9b6448b9feb5876086e 100644 --- a/src/puppet-web/puppet-web.ts +++ b/src/puppet-web/puppet-web.ts @@ -16,6 +16,8 @@ * limitations under the License. * */ +import * as mime from 'mime' + import { config, log, @@ -326,7 +328,8 @@ export class PuppetWeb extends Puppet { const filename = mediaMessage.filename() const ext = mediaMessage.ext() - const contentType = Misc.mime(ext) + // const contentType = Misc.mime(ext) + const contentType = mime.getType(ext) let mediatype: MediaType switch (ext) {