activestorage-delayed 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -3
- data/lib/activestorage-delayed/delayed_uploader.rb +3 -2
- data/lib/activestorage-delayed/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 153ae98174a2430ab5b0ddfb3a2bb17ffc6b0d568306ba9b2ee55886d4b16581
|
4
|
+
data.tar.gz: a75a0db4f5a200a84a627bdf74771ee63d39260b2df769a94ecc1a93a8f75546
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76a311ff87cc7ecf0046443834e1940563d2ed69bafc50f8d5cabbd0d7643c72f1827fb8ab89a86adf60f3e20856192d3412d9cfc8704aed3e8204f8b5379a21
|
7
|
+
data.tar.gz: 87dc98a976a1c8cbcc0a64bbda6acd3d04e3bbd42d388640ad168627e1a89e1719a17ba07735292a715ed733000e8f11b08570a5415e9bd3ca24560f311e6342
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
# Activestorage Delayed
|
2
2
|
|
3
|
-
ActiveStorage
|
4
|
-
This is a Ruby on Rails gem to upload activestorage files in background by saving them as base64 encoded in the database and be processed later.
|
3
|
+
ActiveStorage in Rails 6 and 7 does not support to upload files in background which in most cases delays the submit process and then makes the visitor get bored or receive a timeout error.
|
4
|
+
This is a Ruby on Rails gem to upload activestorage files in background by saving them as base64 encoded in the database (important for apps hosted in kubernetes) and be processed later.
|
5
|
+
|
6
|
+
## Features
|
7
|
+
- Upload files in background
|
8
|
+
- Ability to add new files instead of replacing the old ones when using using `has_many_attached`
|
9
|
+
- Ability to upload files with the original filename or a custom one
|
10
|
+
- Ability to preprocess the files before uploading them (Rails 7+)
|
11
|
+
Note: This gem assumes that the app has already configured activestorage.
|
5
12
|
|
6
13
|
## Installation
|
7
14
|
- Add this line to your application's Gemfile:
|
8
15
|
```ruby
|
9
|
-
gem 'activestorage-delayed'
|
16
|
+
gem 'activestorage-delayed', '>= 0.1.1'
|
10
17
|
```
|
11
18
|
- And then execute: `bundle install`
|
12
19
|
- Generate the migration: `rails g migration add_activestorage_delayed`
|
@@ -13,8 +13,7 @@ module ActivestorageDelayed
|
|
13
13
|
return unless delayed_upload
|
14
14
|
|
15
15
|
remove_files
|
16
|
-
upload_photos
|
17
|
-
save_changes
|
16
|
+
save_changes if upload_photos
|
18
17
|
end
|
19
18
|
|
20
19
|
private
|
@@ -25,9 +24,11 @@ module ActivestorageDelayed
|
|
25
24
|
tmp_files_data.each do |file_data|
|
26
25
|
model.send(attr_name).attach(file_data.transform_keys(&:to_sym))
|
27
26
|
end
|
27
|
+
true
|
28
28
|
rescue => e # rubocop:disable Style/RescueStandardError
|
29
29
|
Rails.logger.error("********* #{self.class.name} -> Failed uploading files: #{e.message}. #{e.backtrace[0..20]}")
|
30
30
|
model.ast_delayed_on_error(attr_name, e)
|
31
|
+
false
|
31
32
|
end
|
32
33
|
|
33
34
|
def save_changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage-delayed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Peredo Diaz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|