Skip to content

Commit 49e7936

Browse files
committed
chore: improve storage form
1 parent 1f85aba commit 49e7936

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pages/storage.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ const { data: storage } = await useFetch('/api/storage')
1414
1515
async function addFile () {
1616
const key = newFileKey.value.trim().replace(/\s/g, '-')
17-
if (!key || !newFileValue.value) { return }
17+
if (!key || !newFileValue.value) {
18+
toast.add({ title: `Missing ${!key ? 'key' : 'file'}.`, color: 'red' })
19+
return
20+
}
1821
1922
loading.value = true
2023
@@ -54,6 +57,9 @@ function onFileSelect (e) {
5457
const files = [...(target.files || [])]
5558
if (files.length) {
5659
newFileValue.value = files[0]
60+
if (!newFileKey.value.trim()) {
61+
newFileKey.value = files[0].name
62+
}
5763
}
5864
5965
// Clear the input value so that the same file can be uploaded again

0 commit comments

Comments
 (0)