anaconda 0.9.10 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec2d1ef0a9efcf1065ca2210f211c9a20653b662
4
- data.tar.gz: 4ca928455cb8bc4be2ae93b5b5d4d03c9db0900e
3
+ metadata.gz: 830e53717f29f2229e104f5fedbe270bf7ae0fec
4
+ data.tar.gz: 744677a55ffeb7cfe4f8ff5590aa67b2eb6f5031
5
5
  SHA512:
6
- metadata.gz: c5f122214ac0b2fa4cdde29f29ec2d1d6ba421d7213bdcd344795958a72bb6b9d8083eb1f1a68c318c36d8253488c9d884a37e8440c44c40c625030bcea7de69
7
- data.tar.gz: 9d0c53d7bd5e1aa15ccf81f320e0225826824b23d705473aa80426d3b439e5414e496ecd8c5ffd9c5c74ae50a59f61c35f7e14c41862d5ba911437d0f323f9ff
6
+ metadata.gz: 9287ef9d60d71561104edb806c5f571a0729fb55831286e21a287e191402d932fab6d135645f00f3c6233cf27a7dcf7eb8749f221f7251249001c3010b66852f
7
+ data.tar.gz: 1d31ca5e855d8a361752685e2b0add17ca3faddb2c4a2913d95607d86935f7c5ac4b9380dafb8da85226b9bad7fb64b973bf4ddd03517c47c71b534569fdf841
@@ -149,9 +149,16 @@ We highly recommend the `figaro` gem [https://github.com/laserlemon/figaro](http
149
149
  * :asset_type
150
150
  * :asset_url
151
151
 
152
- The magic method is asset_url which will return a signed S3 URL if the file is stored with an ACL of `private` and will return a non-signed URL if the file is stored with public access.
152
+ The magic methods are asset_url and asset_download_url.
153
+
154
+ `asset_url` will return a signed S3 URL if the file is stored with an ACL of `private` and will return a non-signed URL if the file is stored with public access.
155
+
156
+ `asset_download_url` will return a signed S3 URL with content-disposition set to attachment so the file will be downloaded instead of opened in the browser.
153
157
 
154
158
  ## Changelog
159
+ * 0.10.0
160
+ * Add `download_url` magic method that uses content-disposition to force the browser to download the URL. This is a signed AWS url that is only valid for 1 hour
161
+
155
162
  * 0.9.10
156
163
  * Fix bug when attribute had more than one underscore
157
164
 
@@ -1,3 +1,3 @@
1
1
  module Anaconda
2
- MagicMethods = [:url]
2
+ MagicMethods = [:url, :download_url]
3
3
  end
@@ -55,6 +55,8 @@ module Anaconda
55
55
  case checking_method
56
56
  when :url
57
57
  anaconda_url(checking_column)
58
+ when :download_url
59
+ anaconda_download_url(checking_column)
58
60
  else
59
61
  super
60
62
  end
@@ -77,6 +79,15 @@ module Anaconda
77
79
  end
78
80
  end
79
81
 
82
+ def anaconda_download_url(column_name)
83
+ return nil unless send("#{column_name}_file_path").present?
84
+
85
+ options = {query: {"response-content-disposition" => "attachment;"}}
86
+ aws = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => Anaconda.aws[:aws_access_key], :aws_secret_access_key => Anaconda.aws[:aws_secret_key]})
87
+ aws.get_object_https_url(Anaconda.aws[:aws_bucket], send("#{column_name}_file_path"), 1.hour.from_now, options)
88
+
89
+ end
90
+
80
91
  def anaconda_protocol(column_name)
81
92
  case self.anaconda_options[column_name.to_sym][:protocol]
82
93
  when :auto
@@ -1,5 +1,5 @@
1
1
  module Anaconda
2
2
  module Rails
3
- VERSION = "0.9.10"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anaconda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben McFadden