feat: add message attachments (wip)
This commit is contained in:
+30
-1
@@ -1,3 +1,32 @@
|
||||
<template>
|
||||
<script setup lang="ts">
|
||||
const uploadFile = async () => {
|
||||
const fileInput = document.querySelector('input[type="file"]') as HTMLInputElement;
|
||||
if (!fileInput?.files?.[0]) return;
|
||||
|
||||
const file = fileInput.files[0];
|
||||
const mimeType = file.type || 'application/octet-stream';
|
||||
|
||||
const { url } = await $fetch('/api/upload/presigned', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
file: {
|
||||
name: file.name,
|
||||
mimeType: mimeType,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const res = await fetch(url, {
|
||||
method: 'PUT',
|
||||
body: file,
|
||||
headers: {
|
||||
'Content-Type': mimeType,
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input type="file" />
|
||||
<button @click="uploadFile">Upload</button>
|
||||
</template>
|
||||
Reference in New Issue
Block a user