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 +4 -4
- data/lib/anaconda/anaconda_for.rb +27 -0
- data/lib/anaconda/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15005913b55226589abb23fbe8830d98c1e6e18f
|
4
|
+
data.tar.gz: e58a9d025a944d40b81f4d910a7d3a5dc11d5a72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/anaconda/version.rb
CHANGED