Closed
Description
On the servers-side:
// api/upload.post.ts
export default eventHandler(event => {
// Do auth checks...
return hubBlob().handleUpload(event, {
formKey: 'file', // default
multiple: true | false, // throw error if multiple files & false, default true
// ... put() options
// ensureBlob() options
})
})
We should add a prefix
option to put()
to we can also have it in handleUpload(event)
On the app side:
<script setup>
async function upload(e: Event) {
const { pathname } = await useUpload('/api/upload')(e.target.image)
}
</script>
<template>
<div>
<h3>Images</h3>
<form @submit.prevent="upload">
<label>Upload an image: <input type="file" name="image"></label>
<button type="submit">
Upload
</button>
</form>
</template>