lib/microstatic/s3_deployer.rb in microstatic-0.3.0 vs lib/microstatic/s3_deployer.rb in microstatic-0.4.0

- old
+ new

@@ -29,21 +29,27 @@ s3_object = false end if !s3_object log_action('CREATE', s3_key) - connection.put_object( @bucket, s3_key, file.open, 'x-amz-acl' => 'public-read' ) + put_file( s3_key, file ) else s3_md5 = s3_object.headers['ETag'].sub(/"(.*)"/,'\1') local_md5 = Digest::MD5.hexdigest( file.read ) if( s3_md5 == local_md5 ) log_action('NO CHANGE', s3_key) else log_action('UPDATE', s3_key) - connection.put_object( @bucket, s3_key, file.open ) + put_file( s3_key, file ) end end + end + + private + + def put_file( s3_key, file ) + connection.put_object( @bucket, s3_key, file.open, 'x-amz-acl' => 'public-read', 'x-amz-storage-class' => 'REDUCED_REDUNDANCY' ) end def log_action(action,file) message = action.to_s.rjust(10) + " " + file puts message