/** Uploads a file to an S3/MinIO presigned POST URL (see lib/storage.ts's
 * createPresignedUploadPost) — unlike a presigned PUT, the storage server
 * itself rejects a mismatched size via the signed content-length-range
 * condition, so this can't be used to upload past the declared limit. */
export async function uploadToPresignedPost(
  url: string,
  fields: Record<string, string>,
  file: File
): Promise<boolean> {
  const formData = new FormData();
  for (const [key, value] of Object.entries(fields)) formData.append(key, value);
  formData.append("file", file);
  const res = await fetch(url, { method: "POST", body: formData });
  return res.ok;
}
