Multipart upload compatibility with 1.8.7

This commit is contained in:
Steven Bazyl 2012-03-13 14:39:44 -07:00 committed by Bob Aman
parent eec8c167cb
commit 11bae1fde0
1 changed files with 5 additions and 5 deletions

View File

@ -66,17 +66,17 @@ module Google
:request => { :boundary => MULTIPART_BOUNDARY } :request => { :boundary => MULTIPART_BOUNDARY }
} }
multipart = Faraday::Request::Multipart.new multipart = Faraday::Request::Multipart.new
self.body = multipart.create_multipart(env, { self.body = multipart.create_multipart(env, [
:metadata => Faraday::UploadIO.new(metadata, 'application/json'), [nil,Faraday::UploadIO.new(metadata, 'application/json', 'file.json')],
:content => self.media}) [nil, self.media]])
self.headers.update(env[:request_headers]) self.headers.update(env[:request_headers])
when "resumable" when "resumable"
file_length = self.media.length file_length = self.media.length
self.headers['X-Upload-Content-Type'] = self.media.content_type self.headers['X-Upload-Content-Type'] = self.media.content_type
self.headers['X-Upload-Content-Length'] = file_length.to_s self.headers['X-Upload-Content-Length'] = file_length.to_s
if options[:body_object] if options[:body_object]
self.headers['Content-Type'] ||= 'application/json' self.headers['Content-Type'] ||= 'application/json'
self.body = serialize_body(options[:body_object]) self.body = serialize_body(options[:body_object])
else else
self.body = '' self.body = ''
end end