openresty / openresty/lua-resty-upload
If the uploaded file is a picture,I want it to be a 2048 by 2048 image with maximum height and width
Open
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 414
- Forks
- 110
- Avg merge
- 2h 43m
- Merged PRs (30d)
- 1
Description
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
local key = res[1]
local value = res[2]
if key == "Content-Disposition" then
local kvlist = string.split(value, ';')
for _, kv in ipairs(kvlist) do
local seg = string.trim(kv)
if seg:find("filename") then
local kvfile = string.split(seg, "=")
local filename = string.sub(kvfile[2], 2, -2)
if filename then
ext = getExtension(filename)
local now = os.date("%Y%m%d%H%M%S", os.time())
local filename = now.."-"..string.sub(ngx.md5(now..user_cid), 0, 8)..ext
local image_id = ""
if string.find(uri, "/upload/photo") then
uri = string.gsub(ngx.var.uri, '/upload/photo', "/bfs/g/"..filename)
image_id = "/g/"..filename
elseif string.find(uri, "/upload/voice") then
uri = string.gsub(ngx.var.uri, '/upload/voice', "/bfs/v/"..filename)
else
ngx.print(cjson.encode({code=404, message="Not Found"}))
ngx.exit(404)
end
break
end
end
end
end
--append body
elseif typ == "body" then
if res then
appender = appender..res
end
--one file has been read
elseif typ == "part_end" then
if appender ~= '' then
-- If the uploaded file is a picture,I want it to be a 2048 by 2048 image with maximum height and width
code = upload2BFS(uri, data)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /upload/photo branch in the upload loop and trace how the uploaded data reaches upload2BFS(uri, data). Determine how picture files are identified and how the 2048 maximum height and width requirement should be applied. Done should be demonstrated by verified picture-upload behavior, but the issue does not name tests or implementation files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100