Files
modrinth/packages/ui/src/providers/file-picker.ts
T
Calum H. 87ff8fd4d9 fix: server panel not using correct endpoint for mrpack reupload (#6539)
fix: server panel not using correct endpoint for local modpack reupload
2026-06-29 14:39:03 +00:00

32 lines
1.1 KiB
TypeScript

import { createContext } from '.'
export interface PickedFile {
/** Browser File object */
file: File
/** Native file system path (available on Tauri, undefined on web) */
path?: string
/** URL suitable for display (blob URL on web, convertFileSrc URL on Tauri) */
previewUrl: string
}
export interface PickedModpackFile extends Omit<PickedFile, 'file'> {
/** Only present for upload flows; native imports avoid copying huge packs into the browser heap. */
file?: File
}
export interface PickModpackFileOptions {
/** Set to false when a native path can be streamed directly by the backend. */
readFile?: boolean
}
export interface FilePickerProvider {
/** Pick an image file (for icons) */
pickImage: () => Promise<PickedFile | null>
/** Pick one or more generic files */
pickFiles?: (options?: { multiple?: boolean }) => Promise<PickedFile[]>
/** Pick a .mrpack modpack file */
pickModpackFile: (options?: PickModpackFileOptions) => Promise<PickedModpackFile | null>
}
export const [injectFilePicker, provideFilePicker] = createContext<FilePickerProvider>('FilePicker')