简体   繁体   English

Rails 5 - 在数据库中存储活动存储文件

[英]Rails 5 - Store Active Storage files in the database

We have an existing Rails 5.2.3 project with file uploads implemented in various places.我们有一个现有的 Rails 5.2.3 项目,在不同的地方实现了文件上传。 Active Storage is configured to store them on disk in the /storage directory, but there is now a requirement that we store files in a database table instead. Active Storage 被配置为将它们存储在磁盘上的 /storage 目录中,但现在要求我们将文件存储在数据库表中。

Is it possible to configure Active Storage to store files in a database table?是否可以将 Active Storage 配置为将文件存储在数据库表中? I've had a look through the docs and I can't seem to find anything.我浏览了文档,但似乎找不到任何东西。

If you really want to do that...如果你真的想这样做...

Found this gem for Active Storage.为 Active Storage 找到了这个gem

You can also do it with Refile if you are using postgres as db如果您使用 postgres 作为数据库,您也可以使用Refile

I've using another gem .我正在使用另一个gem For small files it's working great.对于小文件,它工作得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM