def write(data = nil, headers = {})
raise CloudFiles::Exception::Syntax, "No data or header updates supplied" if ((data.nil? && $stdin.tty?) and headers.empty?)
if headers['Content-Type'].nil?
type = MIME::Types.type_for(self.name).first.to_s
if type.empty?
headers['Content-Type'] = "application/octet-stream"
else
headers['Content-Type'] = type
end
end
data = $stdin if (data.nil? && $stdin.tty? == false)
response = self.container.connection.storage_request("PUT", @storagepath, headers, data)
code = response.code
raise CloudFiles::Exception::InvalidResponse, "Invalid content-length header sent" if (code == "412")
raise CloudFiles::Exception::MisMatchedChecksum, "Mismatched etag" if (code == "422")
raise CloudFiles::Exception::InvalidResponse, "Invalid response code #{code}" unless (code =~ /^20./)
make_path(File.dirname(self.name)) if @make_path == true
self.refresh
true
end