Skip to content

Commit

Permalink
Merge pull request JosephP91#97 from Adonai/master
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephP91 authored Dec 27, 2016
2 parents d9c54b5 + 8fb9948 commit f6ff8eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/curl_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ namespace curl {
* contents to the form contents list.
*/
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,int> &, const curl_pair<CURLformoption,std::string> &);
/**
* Overloaded add method. Used primarily to pass data via CURLFORM_BUFFERPTR.
* E.g. first option is content name, second is buffer name,
* third is buffer data pointer, fourth is buffer length.
*/
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption, char*> &, const curl_pair<CURLformoption,long> &);
/**
* Overloaded add method. This version is primarily used to upload multiple files.
* You can pass a vector of filenames to upload them.
Expand Down
12 changes: 12 additions & 0 deletions src/curl_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ void curl_form::add(const curl_pair<CURLformoption,string> &form_name, const cur
}
}

// Implementation of add overloaded method for CURLFORM_BUFFERPTR uses
void curl_form::add(const curl_pair<CURLformoption,string> &form_name, const curl_pair<CURLformoption,string> &form_bufname, const curl_pair<CURLformoption, char*> &form_content, const curl_pair<CURLformoption,long> &content_length) {
if (curl_formadd(&this->form_post,&this->last_ptr,
form_name.first(),form_name.second(),
form_bufname.first(),form_bufname.second(),
form_content.first(),form_content.second(),
content_length.first(),content_length.second(),
CURLFORM_END) != 0) {
throw curl_exception("Error while adding the form",__FUNCTION__);
}
}

/**
* If you want to upload more than one file, you can pass the form name and a
* vector of filenames.
Expand Down

0 comments on commit f6ff8eb

Please sign in to comment.