Media / foldkit-media/browser

uploadFile

function · packages/media/src/browser/upload.ts:160

function uploadFile(
  file: File,
  options?: UploadOptions,
): Stream.Stream<FileUploadEvent, UploadFailed>

Sends any file to the file route (/_media/files by default): Progressed as the bytes go, then one FileUploaded with the facts to claim on save. The body goes as application/octet-stream, which no page can send to another site without a preflight, and the file's name and type in headers of their own; a file the browser gives no type is declared application/octet-stream. A refusal fails it with UploadFailed, as does a file name that cannot be sent (Malformed, status 0).