admin管理员组文章数量:1122832
I'm wanting to have the user select a data file and select a directory (different than the data file location) for images to be imported using active_storage as a background_job in Ruby on Rails.
What type of field can I use in form_with that will allow the file path to be saved for active storage to use after the data file has been imported?
I tried a file_field :photos_path
to select a directory in the form
Then in the controller get the path in the params
if params[:report][:photos_path].present?
@report.photos_path = params[:report][:photos_path].path
p @report.photos_path
end
but that returns the active storage tmp path
11:27:18 web.1 | "/var/folders/bm/6t88t37133d2b6_j1npz5qn80000gn/T/RackMultipart20241121-84847-g5ihzm.csv"
The actual goal is to provide a unique folder directory for active storage to use to import images after the data file has already been imported.
record.photo.attach(io: File.open(Rails.public_path.join("#{file_path}/#{image_name}")), filename: "#{image_name}.jpg", content_type: "image/jpeg", identify: false)
本文标签: rubyrails formwith save file path to database for active storage to import imagesStack Overflow
版权声明:本文标题:ruby - rails form_with save file path to database for active storage to import images - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307575a1933359.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论