class Chef::Provider::RemoteFile::NetworkFile
Constants
- TRANSFER_CHUNK_SIZE
Attributes
new_resource[R]
Public Class Methods
new(source, new_resource, current_resource)
click to toggle source
# File lib/chef/provider/remote_file/network_file.rb, line 34 def initialize(source, new_resource, current_resource) @new_resource = new_resource @source = source end
Public Instance Methods
fetch()
click to toggle source
Fetches the file on a network share, returning a Tempfile-like File
handle windows only
# File lib/chef/provider/remote_file/network_file.rb, line 41 def fetch begin tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile Chef::Log.trace("#{new_resource} staging #{@source} to #{tempfile.path}") with_user_context(new_resource.remote_user, new_resource.remote_password, new_resource.remote_domain, new_resource.authentication) do ::File.open(@source, "rb") do |remote_file| while data = remote_file.read(TRANSFER_CHUNK_SIZE) tempfile.write(data) end end end ensure tempfile.close if tempfile end tempfile end