提交 ec5d0f44 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

use NPM module `mime` to getType(ext)

上级 f9332bd0
......@@ -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
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册