129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/octopress-deploy/s3.rb', line 129
def get_file_with_metadata(file, s3_filename)
file_with_options = {
:file => file,
:acl => :public_read
}
.each do |conf|
if conf.has_key? 'filename' and s3_filename.match(conf['filename'])
if @verbose
puts "+ #{remote_path(file)} matched pattern #{conf['filename']}"
end
if conf.has_key? 'expires'
expireDate = conf['expires']
relative_years = /^\+(\d+) year(s)?$/.match(conf['expires'])
if relative_years
expireDate = (Time.now + (60 * 60 * 24 * 365 * relative_years[1].to_i)).httpdate
end
relative_days = /^\+(\d+) day(s)?$/.match(conf['expires'])
if relative_days
expireDate = (Time.now + (60 * 60 * 24 * relative_days[1].to_i)).httpdate
end
file_with_options[:expires] = expireDate
end
if conf.has_key? 'content_type'
file_with_options[:content_type] = conf['content_type']
end
if conf.has_key? 'cache_control'
file_with_options[:cache_control] = conf['cache_control']
end
if conf.has_key? 'content_encoding'
file_with_options[:content_encoding] = conf['content_encoding']
end
end
end
return file_with_options
end
|