Name
form:AddBuffer -- add file upload section from buffer
Synopsis
form:AddBuffer(name, filename, content[, type, headers])
Function
form:AddBuffer() is used to append a file upload section (from a buffer source) when building a multipart/formdata HTTP POST (sometimes referred to as RFC 2388-style posts). Once you've added all the sections you want included, pass the form handle as parameter to #CURLOPT_HTTPPOST. See easy:SetOpt_HTTPPost for details.

You must call form:Free() after the form post has been done to free the resources.

Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with #CURLOPT_HTTPHEADER as usual.

First, there are some basics you need to understand about multipart/formdata posts. Each part consists of at least a NAME and a CONTENTS part. If the part is made for file upload, there are also a stored CONTENT-TYPE and a FILENAME. Below, we'll discuss what options you use to set these properties in the parts you want to add to your post.

The name argument must be a string which provides the name of this part. The name is not allowed to contain zero-valued bytes. The filename argument must be a string which provides the filename field in the content header. The content argument must contain the actual data to send. The optional argument type can be used to set the content-type for the part and the optional argument headers can be used to specify extra headers for the form POST section. This takes a table containing a list and appends the list of headers to those libcurl automatically generates.

Inputs
name
name of the part
filename
filename for the content header
content
actual data to send
type
optional: content-type for the part
headers
optional: extra headers for the POST section

Show TOC