Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Manually Do Upload in ActiveStorage in Rails Console

Permalink

Upload file is at local:

rails console
a=Article.last
a.download_file.attach(io: File.open("/home/deployer/Manual.docx"), filename: "使用手册区.docx")

Upload file is at remote:

rails console
file = URI.open(remote_file_full_url)
a=Article.last
a.download_file.attach(io: file, filename: remote_file_name)

Comments