mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-22 07:07:53 +00:00
refactor(api): use shell provided mime
This commit is contained in:
parent
a91e4bde19
commit
f62febad1e
@ -25,7 +25,6 @@
|
||||
"concurrently": "^8.2.1",
|
||||
"esbuild-register": "^3.5.0",
|
||||
"ipcman": "^0.1.3",
|
||||
"mime": "^4.0.4",
|
||||
"node-fetch": "^3.3.2",
|
||||
"ts-toolbelt": "^9.6.0",
|
||||
"typescript": "~5.1.0"
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { ChronocatContext } from '@chronocat/shell'
|
||||
import mime from 'mime/lite'
|
||||
import fetch from 'node-fetch'
|
||||
import { createReadStream, createWriteStream } from 'node:fs'
|
||||
import { copyFile, mkdir, unlink, writeFile } from 'node:fs/promises'
|
||||
@ -66,7 +65,7 @@ export const commonFile = async (
|
||||
// 从 Content-Type 获得 MIME
|
||||
fileMime ||= response.headers.get('Content-Type') || undefined
|
||||
if (fileMime && !fileName.includes('.')) {
|
||||
const ext = mime.getExtension(fileMime)
|
||||
const ext = ctx.chronocat.mime.getExtension(fileMime)
|
||||
fileName += ext ? '.' + ext : ''
|
||||
}
|
||||
|
||||
@ -85,7 +84,7 @@ export const commonFile = async (
|
||||
if (capture) {
|
||||
fileMime ||= capture[1]!
|
||||
const base64 = capture[2]!
|
||||
const ext = mime.getExtension(fileMime)
|
||||
const ext = ctx.chronocat.mime.getExtension(fileMime)
|
||||
fileName ||= generateToken16() + (ext ? '.' + ext : '')
|
||||
filePath = await saveBuffer(
|
||||
ctx,
|
||||
|
@ -1783,7 +1783,6 @@ __metadata:
|
||||
concurrently: "npm:^8.2.1"
|
||||
esbuild-register: "npm:^3.5.0"
|
||||
ipcman: "npm:^0.1.3"
|
||||
mime: "npm:^4.0.4"
|
||||
node-fetch: "npm:^3.3.2"
|
||||
ts-toolbelt: "npm:^9.6.0"
|
||||
typescript: "npm:~5.1.0"
|
||||
@ -1868,6 +1867,7 @@ __metadata:
|
||||
esbuild-register: "npm:^3.5.0"
|
||||
js-yaml: "npm:^4.1.0"
|
||||
logiri: "npm:^0.1.2"
|
||||
mime: "npm:^4.0.4"
|
||||
node-fetch: "npm:^3.3.2"
|
||||
protobufjs: "npm:^7.2.5"
|
||||
ts-toolbelt: "npm:^9.6.0"
|
||||
|
Loading…
Reference in New Issue
Block a user