-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.vue
46 lines (35 loc) · 1.02 KB
/
debug.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<script setup lang="ts">
import type { PutBlobResult } from '@vercel/blob'
import { ref, useTemplateRef } from 'vue'
const input = useTemplateRef<HTMLInputElement>('inputFileRef')
const blob = ref<PutBlobResult>()
const hls = ref<boolean>()
const onSubmit = async (event: Event) => {
event.preventDefault()
if (!input.value?.files) {
throw new Error('No file selected')
}
const file = input.value.files[0]
const formData = new FormData()
formData.append('file', file)
const response = await fetch(`/api/blob${hls.value ? '?convert=hls' : ''}`, {
method: 'POST',
body: formData,
})
const newBlob = (await response.json()) as PutBlobResult
console.table(newBlob)
blob.value = newBlob
}
</script>
<template>
<h1>Upload Image</h1>
<form @submit="onSubmit">
<input name="file" ref="inputFileRef" type="file" required />
<input type="checkbox" id="hls" name="hls" v-model="hls" />
<label for="hls">Convert video to HLS</label>
<button type="submit">Upload</button>
</form>
<hr />
{{ hls }}
{{ blob }}
</template>