Method: Hyperkit::Client::Containers#write_file
- Defined in:
- lib/hyperkit/client/containers.rb
#write_file(container, dest_file, options = {}) {|io| ... } ⇒ Sawyer::Resource
Write to a file in a container
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'lib/hyperkit/client/containers.rb', line 896 def write_file(container, dest_file, ={}, &block) headers = { "Content-Type" => "application/octet-stream" } headers["X-LXD-uid"] = [:uid].to_s if [:uid] headers["X-LXD-gid"] = [:gid].to_s if [:gid] headers["X-LXD-mode"] = [:mode].to_s(8).rjust(4, "0") if [:mode] if ! block_given? content = [:content].to_s else io = StringIO.new yield io io.rewind content = io.read end post(file_path(container, dest_file), { raw_body: content, headers: headers }) end |