Send2Ebook (receiver) plugin (#3681)

This commit is contained in:
mwoz123
2018-02-23 00:02:32 +01:00
committed by Frans de Jonge
parent 720fd5d826
commit 25a67a2e17
6 changed files with 268 additions and 17 deletions

View File

@@ -6,6 +6,20 @@ local url = require("socket.url")
local FtpApi = {
}
function FtpApi:generateUrl(address, user, pass)
local colon_sign = ""
local at_sign = ""
if user ~= "" then
at_sign = "@"
end
if pass ~= "" then
colon_sign = ":"
end
local replace = "://" .. user .. colon_sign .. pass .. at_sign
local generated_url = string.gsub(address, "://", replace)
return generated_url
end
function FtpApi:nlst(u)
local t = {}
local p = url.parse(u)
@@ -69,4 +83,12 @@ function FtpApi:downloadFile(file_path)
return ftp.get(file_path ..";type=i")
end
function FtpApi:delete(file_path)
local p = url.parse(file_path)
p.argument = string.gsub(p.path, "^/", "")
p.command = "dele"
p.check = 250
return ftp.command(p)
end
return FtpApi