Commit 1213ab16 authored by nano's avatar nano

use path.extname

parent 4292629a
This diff is collapsed.
...@@ -15,9 +15,9 @@ import {UploadOSS} from '../utils'; ...@@ -15,9 +15,9 @@ import {UploadOSS} from '../utils';
import Router = require('koa-router'); import Router = require('koa-router');
const checkFilePath = async (file) => { const checkFilePath = async (file) => {
if (['gz', 'rar', 'zip', '7z', 'x-gzip'].indexOf(mime.lookup(file.path)) === -1) { if (['.gz', '.rar', '.zip', '.7z'].indexOf(path.extname(file.path)) === -1) {
console.log(file); console.log(file);
throw new Error(`Unsupported file type: ${mime.lookup(file.path)}`); throw new Error(`Unsupported file type: ${path.extname(file.path)}`);
} }
}; };
...@@ -82,6 +82,7 @@ export const UploadPackage = async (ctx: Context) => { ...@@ -82,6 +82,7 @@ export const UploadPackage = async (ctx: Context) => {
const filename = uuid.v1(); const filename = uuid.v1();
const archive_path = path.join(__dirname, '../../test/upload'); const archive_path = path.join(__dirname, '../../test/upload');
await fs.ensureDirAsync(archive_path); await fs.ensureDirAsync(archive_path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment