I\'m looking to save a file (in this case an image) located on another http web server using rails 5.2 active storage.
I have an object with a string parameter for s
The simplest way to do this without having to enter filename explicitly is:
url = URI.parse("https://your-url.com/abc.mp3")
filename = File.basename(url.path)
file = URI.open(url)
user = User.first
user.avatar.attach(io: file, filename: filename)
This automatically saves the avatar against that particular user object.
In case you are using a remote service like S3 the URL can be retrieved by:
user.avatar.service_url