On Friday, 10 June 2016 01:41:28 UTC+3, Khushil Dep wrote:
Hello
We're struggling with something we're not sure is possible here at work:
1. We have an upload endpoint where multipart file contents gets sent to
2. We use streaming to save the contents temporarily to a file
3. We scan this file
The problem we have is that the saved file has all the request in and regexing this out with lua is slow.
In essence we could get anything here form DOC to ZIP files and we just want to write the file upload out to the file, not the whole request stream.
Is this possible at all?
This will do it for you automatically (it uses lua-resty-upload):
https://github.com/bungle/lua-resty-reqargs
It is an abstraction, and file uploads are written to temporary files (you can move them from there to your preferred place, move is an atomic operation on fs on same file system).
How to use:
content_by_lua_block {
local get, post, files = require "resty.reqargs"()
}
The look inside files table, eg using penlight:
require "pl.pretty".dump(files)