jekyll-s3-yearofmoo 0.0.8 → 0.0.9
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.
@@ -71,8 +71,25 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
|
71
71
|
paths
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
74
|
+
def customize_file_metadata(file, object)
|
75
|
+
data = { :access => 'public-read' }
|
76
|
+
expiry = find_matching_expires_header(file)
|
77
|
+
if expiry
|
78
|
+
data[:expiry] = expiry
|
79
|
+
end
|
80
|
+
data
|
81
|
+
end
|
75
82
|
|
83
|
+
def find_matching_expires_header(file)
|
84
|
+
headers = @config['expire_headers']
|
85
|
+
raise headers.to_yaml
|
86
|
+
headers.each do |expire|
|
87
|
+
pattern = Regexp.new expire['pattern']
|
88
|
+
value = expire['value']
|
89
|
+
if value =~ pattern
|
90
|
+
return value
|
91
|
+
end
|
92
|
+
end
|
76
93
|
end
|
77
94
|
|
78
95
|
# Please spec me!
|
@@ -97,7 +114,10 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
|
97
114
|
to_upload = local_files
|
98
115
|
to_upload.each do |f|
|
99
116
|
run_with_retry do
|
100
|
-
|
117
|
+
path = "#{dir}/#{f}"
|
118
|
+
metadata = customize_file_metadata(path)
|
119
|
+
raise metadata.to_yaml
|
120
|
+
if AWS::S3::S3Object.store(f, open(path), @s3_bucket, metadata)
|
101
121
|
puts("Upload #{f}: Success!")
|
102
122
|
else
|
103
123
|
puts("Upload #{f}: FAILURE!")
|