mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
chore(server): use native file-type implementation (#6686)
This commit is contained in:
@@ -61,7 +61,6 @@
|
||||
"dotenv": "^16.4.5",
|
||||
"dotenv-cli": "^7.4.1",
|
||||
"express": "^4.19.2",
|
||||
"file-type": "^19.0.0",
|
||||
"get-stream": "^9.0.1",
|
||||
"graphql": "^16.8.1",
|
||||
"graphql-scalars": "^1.23.0",
|
||||
|
||||
@@ -28,3 +28,5 @@ export const mintChallengeResponse = async (resource: string, bits: number) => {
|
||||
if (!resource) return null;
|
||||
return serverNativeModule.mintChallengeResponse(resource, bits);
|
||||
};
|
||||
|
||||
export const getMime = serverNativeModule.getMime;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Readable } from 'node:stream';
|
||||
|
||||
import { crc32 } from '@node-rs/crc32';
|
||||
import { fileTypeFromBuffer } from 'file-type';
|
||||
import { getStreamAsBuffer } from 'get-stream';
|
||||
|
||||
import { getMime } from '../native';
|
||||
import { BlobInputType, PutObjectMetadata } from './provider';
|
||||
|
||||
export async function toBuffer(input: BlobInputType): Promise<Buffer> {
|
||||
@@ -35,8 +35,7 @@ export async function autoMetadata(
|
||||
// mime type
|
||||
if (!metadata.contentType) {
|
||||
try {
|
||||
const typeResult = await fileTypeFromBuffer(blob);
|
||||
metadata.contentType = typeResult?.mime ?? 'application/octet-stream';
|
||||
metadata.contentType = getMime(blob);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user