Use component like this (just written down here with slots, not deeply tested):
<direct-upload :upload-url='..' :multiple='true' :label='Drop files into this area to start upload' @upload='uploadCallback'>
<!-- <slot></slot> Edit default text in drop area --->
<slot name='progress' slot-scope="slotProps">
<span> {{ slotProps.file.filename }} {{slotProps.progress }} </span>
<slot>
</>
<script>
export default {
...
methods: {
uploadCallback({ file, blob }) {
const urlToView = "/rails/active_storage/blobs/" + blob.signed_id + "/" + blob.filename
// To something with it, add to hidden field etc.
}
}
}
Pass result from rails_direct_uploads_url from Rails view/controller down into JS via JSON attributes etc:
my-upload-form(upload-url="#{rails_direct_uploads_url}")