fclay 0.1.13 → 0.1.14

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: 2b7b92b7a729df3df56c94be63fa55bffa4d04ff
4
- data.tar.gz: 48978989481aaebe63b662e03c78cb6dcd0662c1
3
+ metadata.gz: f197422ece28b5976906d21458fd13d6842e5b46
4
+ data.tar.gz: 9b7400d33a79ce3b2b1df03d27794c0af302a7fe
5
5
  SHA512:
6
- metadata.gz: f055070746fab691bf25a8012b912e5152c656ab9e06cae5885a0c2be2033b01de1ca682a0e5e1023e475b231a55340427a361574b07f85c52e47f9671d8a66e
7
- data.tar.gz: e44df41175bdad7956c76e045a2b468a0096240caaa483e5780b18ecf02a99d48a4736d59dc876984b119eb6585f38f73414c84e5bc221f2c18e884bca929f9e
6
+ metadata.gz: 41c3a5b3fee42d7cb383655c855aa5509c1f5e1b5171a287afaf1b97825c449baa8f608a302ee632f6af365ba85f082198a65664456c9502631fd97252786818
7
+ data.tar.gz: e75fdfb6582428a9172f8ff02d11fbb95931430e516f7085be467023da27ce87606d6b2a0c1deac9b66bc3dee352985ced2068184195ab7121ef77af893c691e
@@ -1,3 +1,5 @@
1
+ require 'base64'
2
+
1
3
  module Fclay
2
4
  module Attachment
3
5
 
@@ -109,6 +111,7 @@ module Fclay
109
111
  url += "#{Fclay.configuration.local_url}/#{self.class.name.tableize}"
110
112
  url += "/#{style.to_s}" if style
111
113
  url += "/#{file_name}"
114
+ url += "##{file_key}" if self.class.fclay_options[:encrypted]
112
115
  url
113
116
  end
114
117
 
@@ -160,7 +163,23 @@ module Fclay
160
163
  create_dirs
161
164
  fetch_file_name
162
165
 
163
- FileUtils.mv(path,local_file_path)
166
+
167
+ if self.class.fclay_options[:encoded] == "base64"
168
+ encoded_string = Base64.encode64(File.open(path, "rb").read)
169
+ File.open(path, "wb") do |file|
170
+ file.write(encoded_string)
171
+ end
172
+ end
173
+
174
+
175
+
176
+ if self.class.fclay_options[:encrypted]
177
+ self.file_key = SecureRandom.hex
178
+ `openssl aes-256-cbc -a -salt -in #{path} -out #{local_file_path} -k #{self.file_key}`
179
+ else
180
+ FileUtils.mv(path,local_file_path)
181
+ end
182
+
164
183
  `chmod 0755 #{local_file_path}`
165
184
 
166
185
  delete_tmp_file
@@ -1,3 +1,3 @@
1
1
  module Fclay
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fclay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Galiev