Files
FastGPT/packages/global/common/file/utils.ts
Archer 36d1ff3679 feat: custom domain (#6067)
* perf: faq

* index

* delete dataset

* delete dataset

* perf: delete dataset

* init

* fix: faq

* doc

* fix: share link auth (#6063)

* standard plan add custom domain config (#6061)

* standard plan add custom domain config

* bill detail modal

* perf: vector count api

* feat: custom domain & wecom bot SaaS integration (#6047)

* feat: custom Domain type define

* feat: custom domain

* feat: wecom custom domain

* chore: i18n

* chore: i18n; team auth

* feat: wecom multi-model message support

* chore: wecom edit modal

* chore(doc): custom domain && wecom bot

* fix: type

* fix: type

* fix: file detect

* feat: fe

* fix: img name

* fix: test

* compress img

* rename

* editor initial status

* fix: chat url

* perf: s3 upload by buffer

* img

* refresh

* fix: custom domain selector (#6069)

* empty tip

* perf: s3 init

* sort provider

* fix: extend

* perf: extract filename

---------

Co-authored-by: Roy <whoeverimf5@gmail.com>
Co-authored-by: heheer <heheer@sealos.io>
Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
2025-12-09 23:33:32 +08:00

29 lines
890 B
TypeScript

import path from 'path';
export const isCSVFile = (filename: string) => {
const extension = path.extname(filename).toLowerCase();
return extension === '.csv';
};
export function detectImageContentType(buffer: Buffer) {
if (!buffer || buffer.length < 12) return 'text/plain';
// JPEG
if (buffer[0] === 0xff && buffer[1] === 0xd8 && buffer[2] === 0xff) return 'image/jpeg';
// PNG
const pngSig = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
if (pngSig.every((v, i) => buffer.readUInt8(i) === v)) return 'image/png';
// GIF
const gifSig = buffer.subarray(0, 6).toString('ascii');
if (gifSig === 'GIF87a' || gifSig === 'GIF89a') return 'image/gif';
// WEBP
const riff = buffer.subarray(0, 4).toString('ascii');
const webp = buffer.subarray(8, 12).toString('ascii');
if (riff === 'RIFF' && webp === 'WEBP') return 'image/webp';
return 'text/plain';
}