Skip to content
This repository has been archived by the owner. It is now read-only.

Add JavaScript direct upload support #81

Merged
merged 1 commit into from Jul 27, 2017
Merged

Add JavaScript direct upload support #81

merged 1 commit into from Jul 27, 2017

Conversation

@javan
Copy link
Member

@javan javan commented Jul 27, 2017

πŸ–₯ β†’ ☁️

Fixes #29
Probably fixes #79
Closes #35

def active_storage_meta_tags
safe_join [
tag.meta(name: 'direct-uploads-url', content: rails_direct_uploads_url)
]

This comment has been minimized.

@dhh

dhh Jul 27, 2017
Member

There's only one tag?

This comment has been minimized.

@dhh

dhh Jul 27, 2017
Member

Also, I'm thinking that maybe we should just decorate the specific file input tag with the URL instead. Like we do with other data-url decorations. We'll wrap that into a direct_upload_file_tag anyway.

This comment has been minimized.

@javan

javan Jul 27, 2017
Author Member

Currently, yes. Leaves us open to adding more without introducing a name change like csrf_meta_tags.

This comment has been minimized.

@javan

javan Jul 27, 2017
Author Member

That's supported currently and will take precedence over the the meta tag value.

This comment has been minimized.

@dhh

dhh Jul 27, 2017
Member

So the meta tag is just there to save repeating the URL on the input tags? That seems like a bit of an over-optimization to me. I'd rather just have it on the input tag alone, such that using this feature doesn't require any setup gymnastics.

@javan
Copy link
Member Author

@javan javan commented Jul 27, 2017

Demo / example using these direct upload events: https://gist.github.com/javan/5538692cb37a683db15792be8d05761e

@isaac
Copy link

@isaac isaac commented Jul 27, 2017

@javan looks great! Is there a way to start the upload as soon as the user selects the file(s) rather than when the form is submitted?

@dhh dhh merged commit 6262891 into rails:master Jul 27, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@javan
Copy link
Member Author

@javan javan commented Jul 28, 2017

@isaac not currently, but you can implement that yourself by handling a file input's change event and creating DirectUploads for its Files. See DirectUploadController for example usage.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.