lib/docusign_rest/client.rb in docusign_rest-0.4.0 vs lib/docusign_rest/client.rb in docusign_rest-0.4.1

- old
+ new

@@ -1669,10 +1669,12 @@ # document_id - ID of the document to add # file_path - Local or remote path to file # content_type - optional content type for file. Defaults to application/pdf. # file_name - optional name for file. Defaults to basename of file_path. # file_extension - optional extension for file. Defaults to extname of file_name. + # file_io - Optional: an opened I/O stream of data (if you don't + # want to read from a file) # # The response only returns a success or failure. def add_envelope_document(options={}) options[:content_type] ||= 'application/pdf' options[:file_name] ||= File.basename(options[:file_path]) @@ -1682,10 +1684,14 @@ 'Content-Type' => options[:content_type], 'Content-Disposition' => "file; filename=\"#{options[:file_name]}\"; documentid=#{options[:document_id]}; fileExtension=\"#{options[:file_extension]}\"" } uri = build_uri("/accounts/#{@acct_id}/envelopes/#{options[:envelope_id]}/documents/#{options[:document_id]}") - post_body = open(options[:file_path]).read + post_body = if options[:file_io].present? + options[:file_io].read + else + open(options[:file_path]).read + end http = initialize_net_http_ssl(uri) request = Net::HTTP::Put.new(uri.request_uri, headers(headers)) request.body = post_body response = http.request(request)