lib/auto-ali-cdn/oss.rb in 2cdn-0.1.3 vs lib/auto-ali-cdn/oss.rb in 2cdn-0.1.4
- old
+ new
@@ -65,9 +65,10 @@
upload_c = ->(res_path) do
Dir.foreach(res_path) do |name|
next if name =~ /^(\.)|(\.\.)$/
file_path = res_path+"/#{name}"
file_md5 = Digest::MD5.hexdigest(File.read(file_path))
+ res_type = res_path.gsub(/^.*\//, '')
suffix = name.split(/\./).last
object_key = config.site_resource_path+"/#{res_type}/#{name.gsub(/#{suffix}$/, "-#{file_md5}#{suffix}")}"
if bucket.object_exists?(object_key)
puts "#{name} --> #{object_key}".color(:dimgray)
replace_res_path.call(res_type+'/'+name, config.domain_name+'/'+object_key)