mirror of
https://github.com/antos-rde/antos-backend.git
synced 2024-11-19 20:08:24 +01:00
fix: file upload
All checks were successful
gitea-sync/antos-backend/pipeline/head This commit looks good
All checks were successful
gitea-sync/antos-backend/pipeline/head This commit looks good
This commit is contained in:
parent
0974679023
commit
beec8b9350
@ -186,8 +186,9 @@ end
|
||||
function VFSController:upload(...)
|
||||
auth_or_die("User unauthorized. Please login")
|
||||
local vfs = require("vfs")
|
||||
if REQUEST and REQUEST.path then
|
||||
local r, m = require("vfs").upload(REQUEST.path)
|
||||
--LOG_DEBUG("UPLOAD COMMAND: %s", JSON.encode(REQUEST))
|
||||
if REQUEST and REQUEST.multipart and REQUEST.multipart.path then
|
||||
local r, m = require("vfs").upload(REQUEST.multipart.path)
|
||||
if r then
|
||||
result(r)
|
||||
else
|
||||
|
10
libs/vfs.lua
10
libs/vfs.lua
@ -149,11 +149,13 @@ vfs.upload = function(path)
|
||||
if (r) then
|
||||
local uid = ulib.uid(SESSION.user)
|
||||
local index = 0
|
||||
while (REQUEST["upload-" .. index .. ".tmp"] ~= nil) do
|
||||
local file = m .. "/" .. REQUEST["upload-" .. index .. ".file"]
|
||||
local ret = ulib.move(REQUEST["upload-" .. index .. ".tmp"], file)
|
||||
while (REQUEST.multipart["upload-" .. index] ~= nil) do
|
||||
local file_data = JSON.decodeString(REQUEST.multipart["upload-" .. index])
|
||||
|
||||
local file = m .. "/" .. file_data.file
|
||||
local ret = ulib.move(file_data.tmp, file)
|
||||
if not ret then
|
||||
ret = ulib.send_file(REQUEST["upload-" .. index .. ".tmp"], file)
|
||||
ret = ulib.send_file(file_data.tmp, file)
|
||||
end
|
||||
if not ret then
|
||||
return false, "Unable to copy file"
|
||||
|
Loading…
Reference in New Issue
Block a user