Skip to content
Browse files

Add custom headers support based on regexp

  • Loading branch information...
1 parent 061f45b commit 643d82b2b3b98afd4bb0355a127339bb66a4c83e @cfcosta committed
Showing with 13 additions and 1 deletion.
  1. +2 −0 lib/asset_sync/config.rb
  2. +11 −1 lib/asset_sync/storage.rb
View
2 lib/asset_sync/config.rb
@@ -11,6 +11,7 @@ class Invalid < StandardError; end
attr_accessor :fail_silently
attr_accessor :always_upload
attr_accessor :ignored_files
+ attr_accessor :custom_headers
attr_accessor :prefix
attr_accessor :public_path
attr_accessor :enabled
@@ -49,6 +50,7 @@ def initialize
self.fail_silently = false
self.always_upload = []
self.ignored_files = []
+ self.custom_headers = {}
self.enabled = true
load_yml! if defined?(Rails) && yml_exists?
end
View
12 lib/asset_sync/storage.rb
@@ -148,10 +148,20 @@ def upload_file(f)
:content_encoding => 'gzip'
})
end
+
+ add_custom_headers(file)
+
@juwalter
juwalter added a note

how about something like file = file.merge(custom_headers) ?

@cfcosta Owner
cfcosta added a note

Because there can be more than one matching rule for each file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
log "Uploading: #{f}"
end
- file = bucket.files.create( file ) unless ignore
+ bucket.files.create(file) unless ignore
+ end
+
+ def add_custom_headers(file)
+ headers = config.custom_headers.select { |(key, _)| file[:key] =~ key }
+ return unless headers
+
+ headers.values.each { |h| file.merge! h }
end
def upload_files

0 comments on commit 643d82b

Please sign in to comment.
Something went wrong with that request. Please try again.