|
1 | 1 | # Active Storage DB |
| 2 | + |
2 | 3 | [](https://badge.fury.io/rb/active_storage_db) |
3 | 4 | [](https://github.com/blocknotes/active_storage_db/actions/workflows/linters.yml) |
4 | 5 | [](https://github.com/blocknotes/active_storage_db/actions/workflows/postgres.yml) |
|
7 | 8 | An Active Storage service upload/download plugin that stores files in a PostgreSQL or MySQL database. |
8 | 9 |
|
9 | 10 | Main features: |
| 11 | +- supports Rails 6.0, 6.1 and 7.0; |
10 | 12 | - all service methods implemented; |
11 | | -- data is saved using a binary field (or blob); |
12 | | -- RSpec tests. |
| 13 | +- attachment data stored in a binary field (or blob). |
13 | 14 |
|
14 | 15 | Useful also with platforms like Heroku (due to their ephemeral file system). |
15 | 16 |
|
16 | 17 | ## Installation |
| 18 | + |
17 | 19 | - Setup Active Storage in your Rails application |
18 | 20 | - Add to your Gemfile `gem 'active_storage_db'` (and execute: `bundle`) |
19 | 21 | - Install the gem migrations: `bin/rails active_storage_db:install:migrations` (and execute: `bin/rails db:migrate`) |
20 | 22 | - Add to your `config/routes.rb`: `mount ActiveStorageDB::Engine => '/active_storage_db'` |
21 | 23 | - Change Active Storage service in *config/environments/development.rb* to: `config.active_storage.service = :db` |
22 | 24 | - Add to *config/storage.yml*: |
| 25 | + |
23 | 26 | ``` |
24 | 27 | db: |
25 | 28 | service: DB |
26 | 29 | ``` |
27 | 30 |
|
28 | 31 | ## Misc |
| 32 | + |
29 | 33 | Some rake tasks are available: |
| 34 | + |
30 | 35 | - `asdb:list`: list the stored attachments |
31 | 36 | - `asdb:get`: download an attachment (ex. `bin/rails "asdb:get[ruby-logo.png,/tmp]"`) |
32 | 37 |
|
33 | 38 | ## Do you like it? Star it! |
| 39 | + |
34 | 40 | If you use this component just star it. A developer is more motivated to improve a project when there is some interest. |
35 | 41 |
|
36 | 42 | Or consider offering me a coffee, it's a small thing but it is greatly appreciated: [about me](https://www.blocknot.es/about-me). |
37 | 43 |
|
38 | 44 | ## Contributors |
| 45 | + |
39 | 46 | - [Mattia Roccoberton](https://blocknot.es/): author |
40 | 47 | - Inspired by [activestorage-database-service](https://github.com/TitovDigital/activestorage-database-service) project |
41 | 48 |
|
42 | 49 | ## License |
| 50 | + |
43 | 51 | The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). |
0 commit comments