thorsson_carrierwave 0.4.6 → 0.4.8
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.
- data/lib/carrierwave/storage/right_s3.rb +12 -6
- metadata +2 -2
@@ -3,7 +3,6 @@ require 'right_aws'
|
|
3
3
|
|
4
4
|
module CarrierWave
|
5
5
|
module Storage
|
6
|
-
|
7
6
|
##
|
8
7
|
# Uploads things to Amazon S3 webservices using the RightAWS libraries (right_aws gem).
|
9
8
|
# In order for CarrierWave to connect to Amazon S3, you'll need to specify an access key id, secret key
|
@@ -51,6 +50,7 @@ module CarrierWave
|
|
51
50
|
@uploader = uploader
|
52
51
|
@path = path
|
53
52
|
@base = base
|
53
|
+
@headers = {'x-amz-acl' => uploader.s3_access_policy}.merge(uploader.s3_headers)
|
54
54
|
end
|
55
55
|
|
56
56
|
##
|
@@ -108,13 +108,18 @@ module CarrierWave
|
|
108
108
|
#end
|
109
109
|
|
110
110
|
def store(file)
|
111
|
-
|
111
|
+
# File.open('/home/ivan/output', 'w') {|f| f.write(@path) }
|
112
|
+
connection.put(bucket, @path, file.read,
|
113
|
+
{'x-amz-acl' => @uploader.s3_access_policy,
|
114
|
+
'x-amz-content-type' => @uploader.s3_headers['Content-Type'],
|
115
|
+
'content-type' => @uploader.s3_headers['Content-Type']}#file.content_type
|
116
|
+
)
|
112
117
|
end
|
113
118
|
|
114
119
|
private
|
115
120
|
|
116
121
|
def headers
|
117
|
-
@headers ||=
|
122
|
+
@headers ||= {}
|
118
123
|
end
|
119
124
|
|
120
125
|
def bucket
|
@@ -122,7 +127,8 @@ module CarrierWave
|
|
122
127
|
end
|
123
128
|
|
124
129
|
def connection
|
125
|
-
@
|
130
|
+
RightAws::S3Interface.new(@uploader.s3_access_key_id, @uploader.s3_secret_access_key)
|
131
|
+
#@base.connection
|
126
132
|
end
|
127
133
|
|
128
134
|
end
|
@@ -159,9 +165,9 @@ module CarrierWave
|
|
159
165
|
end
|
160
166
|
|
161
167
|
def connection
|
162
|
-
@connection ||= RightAws::S3Interface.new(uploader.s3_access_key_id, uploader.s3_secret_access_key)
|
168
|
+
@connection ||= RightAws::S3Interface.new(uploader.s3_access_key_id, uploader.s3_secret_access_key, {:logger => Logger.new('/home/ivan/s3.log')})
|
163
169
|
end
|
164
170
|
|
165
171
|
end # RightS3
|
166
172
|
end # Storage
|
167
|
-
end # CarrierWave
|
173
|
+
end # CarrierWave
|