fix: sony arw image upload
This commit is contained in:
@@ -3,7 +3,7 @@ import { Waveform } from "@uiball/loaders";
|
|||||||
|
|
||||||
import { ChatContext } from "@/types/common";
|
import { ChatContext } from "@/types/common";
|
||||||
import useUploadFile from "@/hooks/useUploadFile";
|
import useUploadFile from "@/hooks/useUploadFile";
|
||||||
import { formatBytes, getFileIcon } from "@/utils";
|
import { formatBytes, getFileIcon, shouldPreviewImage } from "@/utils";
|
||||||
import DeleteIcon from "@/assets/icons/delete.svg";
|
import DeleteIcon from "@/assets/icons/delete.svg";
|
||||||
import EditIcon from "@/assets/icons/edit.svg";
|
import EditIcon from "@/assets/icons/edit.svg";
|
||||||
import { useMixedEditor } from "../../MixedInput";
|
import { useMixedEditor } from "../../MixedInput";
|
||||||
@@ -58,7 +58,7 @@ export default function UploadFileList({ context, id }: { context: ChatContext;
|
|||||||
key={url}
|
key={url}
|
||||||
>
|
>
|
||||||
<div className="flex-center w-40 h-40">
|
<div className="flex-center w-40 h-40">
|
||||||
{type.startsWith("image") ? (
|
{shouldPreviewImage(type) ? (
|
||||||
converting ? (
|
converting ? (
|
||||||
<Waveform size={18} lineWeight={3} speed={1} color="#aaa" />
|
<Waveform size={18} lineWeight={3} speed={1} color="#aaa" />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ const useUploadFile = (props?: IProps) => {
|
|||||||
content_type: file_type,
|
content_type: file_type,
|
||||||
filename: name
|
filename: name
|
||||||
});
|
});
|
||||||
|
console.log("prepareUploadFile", resp);
|
||||||
if ("error" in resp) {
|
if ("error" in resp) {
|
||||||
// toast.error("Prepare Upload File Error");
|
// toast.error("Prepare Upload File Error");
|
||||||
return;
|
return;
|
||||||
@@ -119,7 +120,8 @@ const useUploadFile = (props?: IProps) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 出错 则返回
|
// 出错 则返回
|
||||||
if (!uploadResult || "error" in uploadResult) {
|
if (!uploadResult || "error" in uploadResult || !uploadResult.data) {
|
||||||
|
console.error("upload file error uploadResult:", uploadResult);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { path, size, hash } = uploadResult.data as UploadFileResponse;
|
const { path, size, hash } = uploadResult.data as UploadFileResponse;
|
||||||
|
|||||||
+6
-1
@@ -29,7 +29,9 @@ export const getLocalAuthData = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
export const isImage = (file_type = "", size = 0) => {
|
export const isImage = (file_type = "", size = 0) => {
|
||||||
return file_type.startsWith("image") && size <= FILE_IMAGE_SIZE;
|
return (
|
||||||
|
file_type.startsWith("image") && file_type !== "image/x-sony-arw" && size <= FILE_IMAGE_SIZE
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isTreatAsImage = (file: File) => {
|
export const isTreatAsImage = (file: File) => {
|
||||||
@@ -434,3 +436,6 @@ export const transformInviteLink = (link: string) => {
|
|||||||
|
|
||||||
export const isInIframe = () => window.location !== window.parent.location;
|
export const isInIframe = () => window.location !== window.parent.location;
|
||||||
export const encodeBase64 = (str = "") => btoa(unescape(encodeURIComponent(str)));
|
export const encodeBase64 = (str = "") => btoa(unescape(encodeURIComponent(str)));
|
||||||
|
export const shouldPreviewImage = (type: string) => {
|
||||||
|
return type.startsWith("image") && type !== "image/x-sony-arw";
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user