question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Active Storage direct uploads

See original GitHub issue

Working with Active Storage direct uploads when the form is contained by a turbo frame seems not to working as expected.

<turbo-frame ...>
  <form ...>
    <input type="file" data-direct-upload-url="...">
    <input type="submit" ...>
  </form>
</turbo-frame>

Turbo intercepts the form submission and doesn’t allow the direct upload run before do the submit request.

imagen

But, when a form like this is NOT contained by a turbo-frame tag, it works as expected: the file is uploaded and then the form submitted by turbo.

imagen

Is there a workaround or possible solution for this?

Using turbo-rails (0.5.9) by the assets pipeline

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kylekeeslingcommented, Nov 9, 2021

I just tested this and while it seems to work it also appears that the way to setup ActiveStorage in javascript has changed as I’m getting the following error:

Uncaught TypeError: ActiveStorage.start is not a function

Changing my setup to the following seems to do the trick though:

//Old
import * as ActiveStorage from "@rails/activestorage"
ActiveStorage.start()

//New
import "@rails/activestorage"

The Rails docs/guides don’t seem to reflect this change yet, so maybe it’s worth me submitting a PR to update the docs?

0reactions
seanpdoylecommented, Nov 20, 2021

Thank you for following up on this @CharlieIGG. I’ve opened https://github.com/hotwired/turbo/pull/459 to make the changes mentioned by https://github.com/hotwired/turbo/issues/243#issuecomment-818730045.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Active Storage Overview - Rails Edge Guides
If you want to use the Direct Upload feature from a JavaScript framework, or you want to integrate custom drag and drop solutions,...
Read more >
Understanding Rails ActiveStorage Direct Uploads
It is a storage backend agnostic way to upload files from the user's browser directly into the storage backend, bypassing your application ...
Read more >
Direct Uploads with ActiveStorage (Example) - GoRails
Learn how to enable direct uploads in the browser to Amazon S3 or DigitalOcean Spaces using Rails' new ActiveStorage library.
Read more >
direct upload using active storage in rails - Stack Overflow
direct upload using active storage in rails - input.dataset.directUploadUrl "undefined" · javascript · ruby-on-rails · ruby · rails-activestorage ...
Read more >
activestorage - npm
Direct upload installation · Include activestorage.js in your application's JavaScript bundle. Using the asset pipeline: //= require ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found