Problems with uploading a file, claims local and remote file both nil

63 views
Skip to first unread message

Dav Yaginuma

unread,
Aug 12, 2010, 10:29:19 AM8/12/10
to Curb - Ruby libcurl Bindings
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

taf2

unread,
Aug 15, 2010, 9:24:10 PM8/15/10
to Curb - Ruby libcurl Bindings
Reply all
Reply to author
Forward
0 new messages