Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
.ci
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

lua-resty-multipart

Module Version Build Status

multipart/form-data MIME type parser optimized for OpenResty with JIT PCRE.

Note: while this library is an improvement over some other ones out there, it is not implemented in a streaming fashion unlike, for instance, lua-resty-upload. This means that your bodies must be accumulated in the Lua land, potentially exhausting the Lua VM memory. We shall provide a resty.multipart.streaming module for downstream/upstream streamed parsing.

Table of Contents

Motivation

TODO

Back to TOC

Usage

Simple encoder/decoder:

local multipart = require 'resty.multipart'

-- decoding
local res = assert(multipart.unserialize(body?, boundary?))
for i, part in ipairs(res) do
  print(part.name)
end

-- encoding
local body = assert(multipart.serialize({
  {
    name = 'part1',
    headers = {['Content-Disposition'] = 'form-data; name="part1"'},
    value = 'hello world'
  },
  {
    name = 'part2',
    headers = {['Content-Disposition'] = 'form-data; name="part2"'},
    value = 'foo'
  }
}), '------boundary')

Multipart helper:

local multipart = require 'resty.multipart'

local m = assert(multipart.new(body?, boundary?, content_type?))

-- decoding
local res = assert(m:decode())

-- modifying
assert(m:add('new_part', {['Content-Type'] = 'text/plain'}, 'hello world'))
assert(m:remove('name'))

-- encoding
local new_body = assert(m:encode())

Back to TOC

Installation

TODO

Back to TOC

Documentation

TODO

Back to TOC

License

Work licensed under the MIT License.

Back to TOC

About

Multipart parsing library for OpenResty

Topics

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.