MCPcopy Index your code
hub / github.com/pingdotgg/uploadthing / generateMimeTypes

Function generateMimeTypes

packages/shared/src/component-utils.ts:28–50  ·  view source on GitHub ↗
(
  typesOrRouteConfig: string[] | ExpandedRouteConfig,
)

Source from the content-addressed store, hash-verified

26};
27
28export const generateMimeTypes = (
29 typesOrRouteConfig: string[] | ExpandedRouteConfig,
30) => {
31 const fileTypes = Array.isArray(typesOrRouteConfig)
32 ? typesOrRouteConfig
33 : objectKeys(typesOrRouteConfig);
34 if (fileTypes.includes("blob")) return [];
35
36 return fileTypes.map((type) => {
37 if (type === "pdf") return "application/pdf";
38 if (type.includes("/")) return type;
39
40 // Add wildcard to support all subtypes, e.g. image => "image/*"
41 // But some browsers/OSes don't support it, so we'll also dump all the mime types
42 // we know that starts with the type, e.g. image => "image/png, image/jpeg, ..."
43 if (type === "audio") return ["audio/*", ...objectKeys(audio)].join(", ");
44 if (type === "image") return ["image/*", ...objectKeys(image)].join(", ");
45 if (type === "text") return ["text/*", ...objectKeys(text)].join(", ");
46 if (type === "video") return ["video/*", ...objectKeys(video)].join(", ");
47
48 return `${type}/*`;
49 });
50};
51
52export const generateClientDropzoneAccept = (fileTypes: string[]) => {
53 const mimeTypes = generateMimeTypes(fileTypes);

Callers 7

UploadButtonFunction · 0.90
UploadButtonFunction · 0.90
generateUploadButtonFunction · 0.90
setInputPropsFunction · 0.85
ProfilePictureCardFunction · 0.85

Calls 1

objectKeysFunction · 0.90

Tested by

no test coverage detected