How to use Uppy with ActiveStorage Discussion
Great screencast. Any plans for describing how to do the same with Shrine? I liked your old screencasts about Shrine and Tus a lot.
Thank you for doing this video. It's great.
Can you give pointers to how to implement multiple file upload fields on a single form? For example, if I wanted users to upload multiple images in one field and multiple videos in another field?
This is awesome - is it selfish to ask for more? What Ivan is discussing sounds great - would also love to see an Uppy + Shrine episode
Thanks so much for this, Chris. It really helped me refactor my Javascript.
In case anyone else encounters this, I was experiencing some Turbolinks/Uppy madness and it seems to be related to not loading the pack tags for my Uppy-related webpacker pack in the head of the document (I was splitting it so that that the Uppy JS isn't loaded everywhere in the application). Someone in GoRails Slack mentioned using content_for :head
for the pack tags in the view and yield :head
in application.html.erb
, and that seems to have cleared things up. At least for now.
I would like to see a multiple upload example, too. I would also like to see how this works when the form submitted does not validate on the server? How does one reset the form fields especially after uploading files dynamically?
Thanks for showing this. I can see how file uploads can be easier. If I want to have the interface and UX of the dashboard, how do I incorporate that? For example, I like the camera option shown in the uppy demo..
Uppy provides support for a number of different sources (webcam, Google Drive, Instagram, external links, etc), each with their own plugins. Some of the configurations are more complicated than others, but the webcam functionality is pretty straightforward
Import the JS and CSS for the webcam plugin to your Javascript file (the below is for webpacker)
import Webcam from '@uppy/webcam'
import '@uppy/webcam/dist/style.css'
Add the webcam plugin to your Uppy instance in your initializer:
yourUppyInstance.use(Webcam, {
target: Dashboard,
countdown: false,
modes: ['picture'],
mirror: false,
facingMode: 'environment',
})
I discovered a bit of a gotcha in that file data added to the Uppy dashboard via normal file picker interface and the webcam are slightly different. I had to do the following in my Uppy core initializer to add a file name to the blobs that are generated via the webcam. The blob data doesn't have a name attribute but it needs one.
let yourUppyInstance = Uppy({
id: 'document',
// set file name for blob captured from webcam
onBeforeFileAdded: (file, files) => {
if(!file.data.name) {
file.data.name = file.name
}
return file
}
})
Or does anyone have the darn Dropbox plugin working with Active Storage and S3?
What did you end up with in the end? I'm working on getting S3 up-and-running but trying to understand the companion side of things
I've followed your tutorial and haven't been able to get uppy pop up to open upon click of "upload". Any ideas as to why? Is there a way to use it without Webpack?
**Excellent episode Chris! **But then again, you always rock. I was able to implement this and change to Shrine quite easily. It also solved my multiple forms per page issue.
**Quick question: ** I allow an existing image to be deleted from a page with ajax. The result is to replace the video with a new form to allow a new upload. But, using JS to place the new form works, but calling setupUppy() fails as not being found even though the page was rendered with it and it works for the forms populated when the page is first rendered. Any ideas?
Thank you!
- Paul
Hey, great cast, it is really useful for a project i'm currently working on. I just have one tiny problem. When i get to the uppy.reset() part, I'm getting the following error:
[Uppy] [17:41:28] Error: Can’t set state for uppy-screen/shot/2020/05/08/at/2/48/50/png-10-10-1d-1d-10-10-1e-1e-1e-image/png-1117029-1588924136020 (the file could have been removed)
Here's how I'm currently using it:
uppy.on('complete', (result) => {
element.querySelectorAll('[data-pending-upload]').forEach(element => element.parentNode.removeChild(element))
result.successful.forEach(file => {
appendUploadedFile(element, file, field_name)
setPreview(element, file)
})
uppy.reset()
})
Not sure if I'm missing something.
I cant find out how to paste code in this forum so I'm sorry if it looks all messy.
I got Uppy working nicely, but I have an issue when using the progressBar. So the first time it works just fine, but then later uploads don't show the progress, only when it is 100% done.
After deleting my browser cache it starts to work again, any clue?
Turns out uppy bugs out when you have a service worker on the backend.. no clue why