paperclip_upload 1.2.3 → 1.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ab8ed12df64b54b310f81a3e0dc71002872e323
4
- data.tar.gz: 83388e8f681debfac5c1687e5d5e0d1d2953b2ca
3
+ metadata.gz: 229fe1659989638dbad27e1737b15137d73d2e36
4
+ data.tar.gz: ad3a8c0670a128ea5a1010e6703907d16670016e
5
5
  SHA512:
6
- metadata.gz: c95d919e913e76b7386a8a0ef36875f27baae052afc2ec48372df82faf2c2f8057081e5527f7f8c22d49b3366353a6b3fd98bcbb22ad9397263d382744a4e9eb
7
- data.tar.gz: be4ef5c06bdbfa924ce2055567eb5fd515d6a27e442d9f806aecb9d90e2b56089637968cc163c02842ac4b4a092d33fcb060985c1217cc87c3636972cafeba76
6
+ metadata.gz: c79bfb3fdb71460bc8fdfd11355416d529d6ca3f761276eea0be3590d777e0abe84aa1bef8e883cd02b1f3973c44c060fbd1ec784eb6ef8d91785b9749fb2fa9
7
+ data.tar.gz: 2a82884a5a84db66092379a12ca1feba76eada4f32bdde95377a40624a2e9dde97f0c986b579a9d22c62fbf75bebd08d9ce20889713a9400615061245728617f
@@ -2,6 +2,11 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ### v1.2.4
6
+
7
+ ##### Fixed
8
+ * Allow `encoded_[file]` accessor to work with base64 headers.
9
+
5
10
  ### v1.2.3
6
11
 
7
12
  ##### Fixed
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperclip_upload (1.2.3)
4
+ paperclip_upload (1.2.4)
5
5
  active_model_serializers (~> 0.9.3)
6
6
  hashids (~> 1.0, >= 1.0.2)
7
7
  paperclip (~> 4.2, >= 4.2.0)
@@ -11,18 +11,21 @@ module PaperclipUpload
11
11
  attr_accessor upload_identifier_attr_name, upload_attr_name
12
12
 
13
13
  before_validation do
14
- identifier = self.send(upload_identifier_attr_name)
14
+ identifier = send(upload_identifier_attr_name)
15
15
 
16
16
  if identifier
17
17
  found_upload = PaperclipUpload::Upload.find_by_identifier(identifier)
18
- self.send("#{upload_attr_name}=", found_upload)
18
+ send("#{upload_attr_name}=", found_upload)
19
19
  end
20
20
 
21
- upload_object = self.send(upload_attr_name)
21
+ upload_object = send(upload_attr_name)
22
22
 
23
23
  if upload_object
24
- raise "invalid PaperclipUpload::Upload instance" if !upload_object.is_a?(PaperclipUpload::Upload)
25
- self.send("#{_paperclip_attr_name}=", upload_object.file)
24
+ if !upload_object.is_a?(PaperclipUpload::Upload)
25
+ raise "invalid PaperclipUpload::Upload instance"
26
+ end
27
+
28
+ send("#{_paperclip_attr_name}=", upload_object.file)
26
29
  upload_object.destroy
27
30
  end
28
31
  end
@@ -35,19 +38,29 @@ module PaperclipUpload
35
38
  attr_accessor encoded_attr_name
36
39
 
37
40
  before_validation do
38
- encoded_attr = self.send(encoded_attr_name)
39
- StringIO.open(Base64.decode64(encoded_attr)) do |data|
40
- self.send("#{_paperclip_attr_name}=", data)
41
- end if encoded_attr
41
+ encoded_attr = send(encoded_attr_name)
42
+ if encoded_attr
43
+ headerless_encoded_file = encoded_attr.split(",").last
44
+ StringIO.open(Base64.decode64(headerless_encoded_file)) do |data|
45
+ send("#{_paperclip_attr_name}=", data)
46
+ end
47
+ end
42
48
  end
43
49
  end
44
50
 
45
51
  private
46
52
 
47
53
  def build_upload_attr_name(_paperclip_attr_name, _sufix = nil)
48
- prefix = !!upload_options.fetch(:use_prefix, PaperclipUpload.use_prefix) ? _paperclip_attr_name : nil
54
+ if !!upload_options.fetch(:use_prefix, PaperclipUpload.use_prefix)
55
+ prefix = _paperclip_attr_name
56
+ end
57
+
49
58
  upload_attr_name = [prefix, ["upload", _sufix].compact.join("_")].compact.join("_")
50
- raise "you are trying to redefine #{upload_attr_name} attribute" if self.method_defined?(upload_attr_name)
59
+
60
+ if self.method_defined?(upload_attr_name)
61
+ raise "you are trying to redefine #{upload_attr_name} attribute"
62
+ end
63
+
51
64
  upload_attr_name
52
65
  end
53
66
 
@@ -1,3 +1,3 @@
1
1
  module PaperclipUpload
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip_upload
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Segovia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-06 00:00:00.000000000 Z
11
+ date: 2015-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails