Comments (4)
@rhettli We have many production users doing large column of uploads with OpenResty. So I believe it's just mistakes in your own code. If you believe it's a bug in OpenResty, please provide a minimal and standalone example that we can easily run and reproduce the issue on our side. Otherwise we cannot help you with so little info since we are not gods. BTW, you can always join the openresty (Chinese) mailing list for discussions if you prefer Chinese: http://openresty.org/en/community.html
from lua-resty-upload.
maby many people use linux os to dev their project, I use windows xp to develop my project ,so the openresty of window have a problem(bug) that less people find it .i stick my config of nginx and upload code of lua here . please make sure if the openresty of windows have this bug which cause upload file to server can't be open. @agentzh
here is nginx config:
pid tmp/nginx.pid;
worker_processes 1;
events {
worker_connections 4096;
}
http {
sendfile on;
include mime.types;
#default_type application/octet-stream;
# lor initialization
lua_package_path "app/?.lua;./?.lua;;"; #;/usr/local/lor/?.lua
#lua_code_cache on;
server {
listen 8081;
set $template_root '';
# 加载静态文件,匹配到就不会往后匹配了。
location ~ /static {
#alias app/views/static; #app/views/static;
root app/views;
}
location ~ /upload_ {#这里配置上传脚本路由。
content_by_lua_file app/upload.lua;
}
#主目录路由接入
location ~ / {
lua_code_cache off; #仅仅在调试的时候关闭,正式环境需要打开。
content_by_lua_file ./app/main.lua;
}
access_log logs/dev-access.log;
error_log logs/dev-error.log;
}
}
and here is lua upload code(copy form net):
local upload = require ("resty.upload")
local chunk_size = 4096 --如果不设置默认是4096.
local form = upload:new(chunk_size)
local file
local filelen=0
form:set_timeout(1000) -- 1 sec
local osfilepath = "app/views/static/" --文件默认的保存位置
function get_filename(res)
local fname = ngx.re.match(res,'(.+)filename="(.+)"(.*)')
if fname then
return fname[2]
end
end
local i=0
while true do
local typ, res, err = form:read()
if not typ then
ngx.say("failed to read: ", err)
return
end
if typ == "header" then
if res[1] ~= "Content-Type" then
local filename = get_filename(res[2])
if filename then
i=i+1
local filepath = osfilepath .. filename
file = io.open(filepath,"w+")
if not file then
ngx.say("failed to open file ")
return
end
else
end
end
elseif typ == "body" then
if file then
filelen= filelen + tonumber(string.len(res))
file:write(res)
else
end
elseif typ == "part_end" then
if file then
file:close()
file = nil
ngx.say("file upload success")
end
elseif typ == "eof" then
break
else
end
end
if i==0 then --0123456789
ngx.say("please upload at least one file!")
return
end
--return middleware
from lua-resty-upload.
@rhettli On Windows you should open the file as a binary file otherwise it treats it as a text file and writes extra bytes to the file automatically. Basically you should pass the "b" flag to the io.open()
call.
from lua-resty-upload.
@agentzh thx,thank for your. help,this problem make me confusing 'my project delay long time.
I love lua and openresty.
from lua-resty-upload.
Related Issues (20)
- Does this support multiple upload? HOT 4
- rest client上传的binary无法正确获取
- Subrequest question HOT 1
- How to reconstruct body after upload HOT 1
- Publish v0.10 on OPM HOT 1
- error module 'cjson' not found HOT 1
- HTTPS upload? HOT 2
- How to build a module to nginx? HOT 1
- Iterator to work with generic for HOT 1
- lua-nginx-module report http v2 not supported yet unexpectedly HOT 6
- If the uploaded file is a picture,I want it to be a 2048 by 2048 image with maximum height and width
- ngx.exit(415) during read() loop does *not* cleanly exit - binary data spewed in log files
- security issues when use in WAF project
- where will I find the file uploaded
- How to download folder content from nginx server
- Got "closed" error after call read method of resty.upload HOT 3
- 请求解决一下http v2 支持的问题 HOT 1
- Support optional compatibility to LF as line break
- Biblioteca jose do python não chama a função jwt
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-resty-upload.