I'm having problems uploading a file in a PUT using curb 0.7.7.1.
I get
#<Curl::Err::InvalidPostFieldError: Local file and remote file are
both nil curb_postfield.c:474>
even though the file I am specifying exists and is readable.
I tried going into the C/gem code to debug this but got lost in the C
bindings, and decided maybe I should ask since perhaps I'm just doing
something obviously wrong. Any help would be appreciated!
Here is a code snippet, and the full script is here:
http://gist.github.com/521041
put_data = []
put_data << Curl::PostField.content('name', @name) if
self.name
put_data << Curl::PostField.content('birthdate', @birthdate) if
@birthdate
put_data << Curl::PostField.content('height', @height) if
@height
if @photo_file_path
puts "FILE: local:#{@photo_file_path}
remote:#{File.basename(@photo_file_path)}"
put_data << Curl::PostField.file('file', @photo_file_path)
end
# post
begin
c = Curl::Easy.new(PROFILES_URL)
c.multipart_form_post = true
c.http_put(put_data)
rescue Exception => e
p e
p c
end