mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 12:56:05 +00:00
feat: enhance mime type handling and improve file metadata management
Updated mime types to include additional formats for text and application categories. Improved file metadata handling in the Storage class to accurately reflect file properties during uploads. Enhanced the DropzoneInner component with new icons for various file types and refined the MediaInfoModal to support a broader range of text formats for previews.
This commit is contained in:
@@ -71,22 +71,29 @@ export class Storage implements EmitsEvents {
|
||||
|
||||
let info: FileUploadPayload = {
|
||||
name,
|
||||
meta: {
|
||||
size: 0,
|
||||
type: "application/octet-stream",
|
||||
},
|
||||
meta: isFile(file)
|
||||
? {
|
||||
size: file.size,
|
||||
type: file.type,
|
||||
}
|
||||
: {
|
||||
size: 0,
|
||||
type: "application/octet-stream",
|
||||
},
|
||||
etag: typeof result === "string" ? result : "",
|
||||
};
|
||||
|
||||
// normally only etag is returned
|
||||
if (typeof result === "object") {
|
||||
info = result;
|
||||
} else if (isFile(file)) {
|
||||
info.meta.size = file.size;
|
||||
info.meta.type = file.type;
|
||||
}
|
||||
|
||||
// try to get better meta info
|
||||
if (!isMimeType(info.meta.type, ["application/octet-stream", "application/json"])) {
|
||||
if (
|
||||
!info.meta.type ||
|
||||
["application/octet-stream", "application/json"].includes(info.meta.type) ||
|
||||
!info.meta.size
|
||||
) {
|
||||
const meta = await this.#adapter.getObjectMeta(name);
|
||||
if (!meta) {
|
||||
throw new Error("Failed to get object meta");
|
||||
|
||||
@@ -2,8 +2,8 @@ export const Q = {
|
||||
video: ["mp4", "webm"],
|
||||
audio: ["ogg"],
|
||||
image: ["jpeg", "png", "gif", "webp", "bmp", "tiff", "avif", "heic", "heif"],
|
||||
text: ["html", "css", "mdx", "yaml", "vcard", "csv", "vtt"],
|
||||
application: ["zip", "xml", "toml", "json", "json5", "pdf"],
|
||||
text: ["html", "css", "mdx", "yaml", "vcard", "csv", "vtt", "xml"],
|
||||
application: ["zip", "toml", "json", "json5", "pdf", "sql"],
|
||||
font: ["woff", "woff2", "ttf", "otf"],
|
||||
} as const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user