anaconda 2.0.2 → 2.1.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: 57868170a368b59a870fd5cd967b553e13b65583
4
- data.tar.gz: 2c2cc0aae3cb3b388fae8a251d43dcb28e06524d
3
+ metadata.gz: 15005913b55226589abb23fbe8830d98c1e6e18f
4
+ data.tar.gz: e58a9d025a944d40b81f4d910a7d3a5dc11d5a72
5
5
  SHA512:
6
- metadata.gz: 852057515f6e9b772a4b39dd6bc73f812f058e4234884945744f0a8016db7c88751f429336aac94df4cc4a922c15a1fc04118dbfa55f827601c3585e970b9c46
7
- data.tar.gz: 2cdfad1b498549f0fe7f268e3a0ec44fdcd967361dfd582b7712e77640aac0cc73856f7e0532b3631195099a07e381319bc036b2c4e73cfc9be639f28931afd6
6
+ metadata.gz: b74bb6e022b6ba452309a63162c772a0d98dd09caadbbbb3bae699d5d4a32370b81171c55cf95370a8b9c8c61dcd8a2f1b892fbfacfa87f12443425f43dcd770
7
+ data.tar.gz: e3bbb7b70c367e9c0adb8ccca970bb127e377440cccbd9f9aef219b89935c1ca5136a8c411e09d4ef8f0a5550cbe9573b986f165bdd2b6ddce920395f8dada2f
@@ -128,6 +128,33 @@ module Anaconda
128
128
  raise "#{anaconda_column} not configured for anaconda. Misspelling or did you forget to add the anaconda_for call for this field?"
129
129
  end
130
130
  end
131
+
132
+ def import_file_to_anaconda_column(file, column_name, options = {})
133
+ options = options.reverse_merge(self.anaconda_options_for( column_name ))
134
+ logger.debug "Options:"
135
+ logger.debug(options)
136
+
137
+ aws = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => options[:aws_access_key], :aws_secret_access_key => options[:aws_secret_key], :path_style => options[:aws_use_path_style]})
138
+ key = send(options[:base_key])
139
+
140
+ bucket = aws.directories.new(key: options[:aws_bucket])
141
+ file_handle = open(file)
142
+ aws_file = bucket.files.create(
143
+ :key => key,
144
+ :body => file_handle,
145
+ :public => options[:acl] == "public-read"
146
+ )
147
+
148
+ self.update_attributes(
149
+ "#{column_name}_filename" => Pathname.new(file).basename,
150
+ "#{column_name}_file_path" => key,
151
+ "#{column_name}_size" => file_handle.size,
152
+ "#{column_name}_original_filename" => Pathname.new(file).basename,
153
+ "#{column_name}_stored_privately" => !(options[:acl] == "public-read"),
154
+ "#{column_name}_type" => ""
155
+ )
156
+
157
+ end
131
158
 
132
159
  private
133
160
  def anaconda_url(column_name, *args)
@@ -1,5 +1,5 @@
1
1
  module Anaconda
2
2
  module Rails
3
- VERSION = "2.0.2"
3
+ VERSION = "2.1.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: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben McFadden