carrierwave-data 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/lib/carrierwave-data/orm/activerecord.rb +10 -1
- data/lib/carrierwave-data/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3a454807c1919b051e33839c8feaf489bd5a78c
|
4
|
+
data.tar.gz: 79e77650fa7a1c3d02e02ca7e74dd675f421ea55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ab7c48092c11b5aa91cded89cba56f04b823b71ec18b23a6136066fb5942e649095ed5e7a070ed8d8f4eb14d366f1230f0705847d6e0a3abfb45ec773652366
|
7
|
+
data.tar.gz: aa28f8957b295825da961e2f9f00e559e74f44eb1862e4e7b5bdc4a52280d8af43bd724aadac5c1769e700a551189e0a413a5f8502cec9c27a4018ce3ccf75ae
|
data/README.md
CHANGED
@@ -32,11 +32,17 @@ A `User`'s `avatar` can be set using a Base64 encoded string, as follows.
|
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
user = User.new
|
35
|
-
user.avatar_data =
|
35
|
+
user.avatar_data = {
|
36
|
+
data: 'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABuBvAAAABGdBTUE...kJggg==',
|
37
|
+
name: 'avatar',
|
38
|
+
ext: 'jpg'
|
39
|
+
}
|
40
|
+
## or
|
41
|
+
# user.avatar_data = 'iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABuBvAAAABGdBTUE...kJggg=='
|
36
42
|
user.save
|
37
43
|
|
38
44
|
user.avatar? # => true
|
39
|
-
user.avatar # => #<UserAvatarUploader:0x007f9575fddc18 @model=#<User id: 1, avatar: "
|
45
|
+
user.avatar # => #<UserAvatarUploader:0x007f9575fddc18 @model=#<User id: 1, avatar: "...">, @mounted_as=:avatar, ...>
|
40
46
|
````
|
41
47
|
|
42
48
|
## Customizations
|
@@ -26,11 +26,20 @@ module CarrierWave
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def decode_#{column}_data
|
29
|
+
file_filename = decoded_#{column}_filename
|
30
|
+
file_extension = decoded_#{column}_extension
|
31
|
+
|
32
|
+
if @#{column}_data.is_a?(Hash)
|
33
|
+
file_filename = @#{column}_data[:name] || file_filename
|
34
|
+
file_extension = @#{column}_data[:ext] || file_extension
|
35
|
+
@#{column}_data = @#{column}_data[:data]
|
36
|
+
end
|
37
|
+
|
29
38
|
file = Tempfile.new('carrierwave-data')
|
30
39
|
file.binmode
|
31
40
|
file.write(Base64.decode64(@#{column}_data))
|
32
41
|
|
33
|
-
filename = [
|
42
|
+
filename = [file_filename, file_extension].compact.join('.')
|
34
43
|
self.#{column} = ActionDispatch::Http::UploadedFile.new(tempfile: file, filename: filename)
|
35
44
|
end
|
36
45
|
RUBY
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramy Aboul Naga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|