mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Send2Ebook (receiver) plugin (#3681)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user