Skip to content

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 ​

PropTypeDefaultDescription
titlestringnullDrop area text (default from i18n: weS3Dropzone.title / titleMultiple)
multiplebooleanfalseAllows more than one file
acceptedFilesstringnullAccepted extensions, comma-separated (e.g. .csv,.xls,.xlsx)
maxFilesnumber | stringnullMax number of files (1 when not multiple)
hideRemoveAllbooleanfalseHides the "Remove files" button
signedUrlstringundefinedEndpoint used to request the signed URL instead of storage/signed_url
readonlybooleannullNo upload, no remove buttons
disabledbooleannullLike readonly, with disabled styling

readonly and disabled default to null: in that case they are inherited from the parent v-form.

Models ​

BindingTypeDescription
v-modelUploadedFile[]Files uploaded in this session (existing attachments excluded) — emitted only
v-model:existing-attachmentsArray<{ 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 ​

EventPayloadDescription
update:modelValueUploadedFile[]The list of uploaded files changed
progressingbooleantrue when every file has finished uploading, false while some are uploading
reset--The list was cleared (clearFile() or "Remove files")

Exposed methods ​

MethodDescription
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>

Source Code ​