OpenResty POST 获取

OpenResty POST 获取

elseif (request_method == 'POST') then
	ngx.req.read_body() --注意这行代码不能少,否则下面的data为nil
	local data = ngx.req.get_body_data()
	local file,err = io.open("/usr/work/SEP2.0/edev/4/EndDevice.xml", "w") --这里要注意的是给相应的文件夹权限
	if file==nil then
		ngx.print("Couldn't open file: "..err)
    else
		io.output(file)
		io.write(data)
		io.close(file)
    end
	ngx.header['Server']       = 'nextfield server'
	ngx.header['Allow']        = 'GET,HEAD'
	ngx.header['Content-Type'] = 'application/sep+xml'
	--ngx.header['Content-Length'] = ''
	--ngx.header['Location']= surl
	ngx.status = 201
	return

发表评论

电子邮件地址不会被公开。 必填项已用*标注