Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 19x 19x 6x 19x 19x 19x 2x | // Every S3 upload in this app goes through a presigned POST, never a raw PUT
// — see flows-api's uploads/presigned-url.js: only a POST policy lets S3
// itself enforce a size limit (content-length-range) and an exact
// Content-Type match at upload time. Shared by ImageField.vue and
// FileField.vue so there's exactly one place that knows how to talk to that
// presigned-POST contract.
export async function uploadToS3(
file: File,
uploadUrl: string,
uploadFields: Record<string, string>
): Promise<void> {
const formData = new FormData()
for (const [field, value] of Object.entries(uploadFields)) {
formData.append(field, value)
}
formData.append('file', file)
const response = await fetch(uploadUrl, { method: 'POST', body: formData })
if (!response.ok) {
throw new Error('Failed to upload to S3')
}
}
|