mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
- Auto-extract preview images from ZIP/RAR/7z archives during ingestion - Upload custom preview images via package drawer - Select preview from archive contents with on-demand extraction UI - Manually add Telegram channels by t.me link, username, or invite link - Invite code UX: bulk create, copy link, usage tracking, delete confirm - Incomplete upload recovery: verify dest messages on worker startup - Rebuild package DB by scanning destination channel with live progress Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
34 lines
814 B
TypeScript
34 lines
814 B
TypeScript
import path from "path";
|
|
|
|
const IMAGE_EXTENSIONS = new Set(["jpg", "jpeg", "png", "webp", "gif", "bmp"]);
|
|
|
|
/**
|
|
* Check if a file path within an archive is an image.
|
|
*/
|
|
export function isImageFile(filePath: string): boolean {
|
|
const ext = path.extname(filePath).toLowerCase().slice(1);
|
|
return IMAGE_EXTENSIONS.has(ext);
|
|
}
|
|
|
|
/**
|
|
* Get the MIME type for an image file extension.
|
|
*/
|
|
export function getImageMimeType(filePath: string): string {
|
|
const ext = path.extname(filePath).toLowerCase().slice(1);
|
|
switch (ext) {
|
|
case "jpg":
|
|
case "jpeg":
|
|
return "image/jpeg";
|
|
case "png":
|
|
return "image/png";
|
|
case "webp":
|
|
return "image/webp";
|
|
case "gif":
|
|
return "image/gif";
|
|
case "bmp":
|
|
return "image/bmp";
|
|
default:
|
|
return "application/octet-stream";
|
|
}
|
|
}
|