Class: ActiveStorage::Attached
- Inherits:
-
Object
- Object
- ActiveStorage::Attached
- Defined in:
- lib/rails_com/active_storage/activestorage_attached.rb
Defined Under Namespace
Classes: One
Instance Method Summary collapse
Instance Method Details
#url_sync(url) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_com/active_storage/activestorage_attached.rb', line 7 def url_sync(url) filename = File.basename URI(url).path Tempfile.open do |file| file.binmode HTTPX.get(url).body.each do |fragment| file.write fragment end file.rewind self.attach io: file, filename: filename end end |