WeS3Dropzone
Drag & drop / click-to-select file uploader that uploads each file straight to S3 through a signed URL (useApi().uploadFile). Files are validated (extension, duplicates, max count), shown as cards with type icon and size, and can be previewed (images in a dialog, other files in a new window).
Usage
vue
<template>
<we-s3-dropzone
v-model="files"
multiple
accepted-files=".pdf,.jpg,.png"
:max-files="5"
@progressing="allUploaded = $event"
/>
</template>
<script setup lang="ts">
const files = ref([])
const allUploaded = ref(true)
</script>Upload flow
For every file the component POSTs to storage/signed_url (or the signed-url prop endpoint), PUTs the file to the returned url, and adds { key, uuid, url } from the signed URL response to the file. Upload errors are shown with useNotify and the file is removed.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | null | Drop area text (default from i18n: weS3Dropzone.title / titleMultiple) |
multiple | boolean | false | Allows more than one file |
acceptedFiles | string | null | Accepted extensions, comma-separated (e.g. .csv,.xls,.xlsx) |
maxFiles | number | string | null | Max number of files (1 when not multiple) |
hideRemoveAll | boolean | false | Hides the "Remove files" button |
signedUrl | string | undefined | Endpoint used to request the signed URL instead of storage/signed_url |
readonly | boolean | null | No upload, no remove buttons |
disabled | boolean | null | Like readonly, with disabled styling |
readonly and disabled default to null: in that case they are inherited from the parent v-form.
Models
| Binding | Type | Description |
|---|---|---|
v-model | UploadedFile[] | Files uploaded in this session (existing attachments excluded) — emitted only |
v-model:existing-attachments | Array<{ filename, size, extension, key, uuid, url }> | Already stored files, shown without uploading; removing one splices it from this array |
ts
interface UploadedFile {
name: string
size: number
loading: false
s3: { key: string, uuid: string, url: string }
}Events
| Event | Payload | Description |
|---|---|---|
update:modelValue | UploadedFile[] | The list of uploaded files changed |
progressing | boolean | true when every file has finished uploading, false while some are uploading |
reset | -- | The list was cleared (clearFile() or "Remove files") |
Exposed methods
| Method | Description |
|---|---|
getFiles() | Returns all files (existing included) as { key, uuid, name, size, type } (without url) |
clearFile() | Removes all files and emits reset |
Examples
vue
<template>
<we-s3-dropzone
ref="dropzone"
v-model="model"
v-model:existing-attachments="existingAttachments"
multiple
hide-remove-all
signed-url="documents/signed_url"
@reset="onReset"
/>
</template>