Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct upload or chunked file upload support? #448

Open
0000sir opened this issue May 27, 2023 · 2 comments
Open

Direct upload or chunked file upload support? #448

0000sir opened this issue May 27, 2023 · 2 comments

Comments

@0000sir
Copy link

0000sir commented May 27, 2023

Thank you for the great admin framework, but I have a tiny problem recently: Direct upload for active storage is not working, the option direct_upload:true didn't affect the html output, I followed codes in lib/trestle/form/fields/file_field.rb, and have no idea for this.

I'm working with S3 protocol for active storage and direct upload works fine if I use it with scaffold controllers, Here's my code:

file_field :file, direct_upload: true, multiple: true, class: 'hello-director', custom: false, accept: 'text/html'

HTML generated:

<div class="form-group"><label class="control-label" for="video_file">Video</label><input multiple="multiple" class="hello-director" custom="false" accept="text/html" type="file" name="video[file][]" id="video_file"></div>

Everything works except the direct_upload option, What I'm missing?

Please help me with this, or I have to rewrite the hole admin panel myself.

Or, is there any other way to upload files in chunks?

Thank you very much.

BTW: trestle-active_storage Gem not help, seems like the direct_upload was simply ignored

@spohlenz
Copy link
Member

The current releases of Rails (including 7.0.x) don't seem to play well with ActiveStorage when used from an engine. It looks like this may be fixed in 7.1 but in the mean time, you can add the following to your config/initializers/trestle.rb:

config.helper do
  delegate :rails_direct_uploads_url, to: :main_app
end

When rendering ActiveStorage files within the admin, you may also need to precede some route calls with main_app..

@0000sir
Copy link
Author

0000sir commented May 29, 2023

@spohlenz Thank you, direct upload works great (with trestle-active_storage Gem)! It's would be nice if this is documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants