| License | Public Domain |
|---|---|
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Network.FTP.Client
Contents
Description
- withFTP :: String -> Int -> (Handle -> FTPResponse -> IO a) -> IO a
- withFTPS :: String -> Int -> (Handle -> FTPResponse -> IO a) -> IO a
- login :: Handle -> String -> String -> IO FTPResponse
- pasv :: Handle -> IO (String, Int)
- rename :: Handle -> String -> String -> IO FTPResponse
- dele :: Handle -> String -> IO FTPResponse
- cwd :: Handle -> String -> IO FTPResponse
- size :: Handle -> String -> IO Int
- mkd :: Handle -> String -> IO String
- rmd :: Handle -> String -> IO FTPResponse
- pwd :: Handle -> IO String
- quit :: Handle -> IO FTPResponse
- nlst :: Handle -> [String] -> IO ByteString
- retr :: Handle -> String -> IO ByteString
- list :: Handle -> [String] -> IO ByteString
- stor :: Handle -> String -> ByteString -> RTypeCode -> IO ()
- nlstS :: Handle -> [String] -> IO ByteString
- retrS :: Handle -> String -> IO ByteString
- listS :: Handle -> [String] -> IO ByteString
- storS :: Handle -> String -> ByteString -> RTypeCode -> IO ()
- data FTPCommand
- data FTPResponse = FTPResponse {}
- data ResponseStatus
- = Wait
- | Success
- | Continue
- | FailureRetry
- | Failure
- data RTypeCode
- data PortActivity
- data Handle = Handle {
- send :: ByteString -> IO ()
- sendLine :: ByteString -> IO ()
- recv :: Int -> IO ByteString
- recvLine :: IO ByteString
- sIOHandleImpl :: Handle -> Handle
- tlsHandleImpl :: Connection -> Handle
- sendCommand :: Handle -> FTPCommand -> IO FTPResponse
- sendCommands :: Handle -> [FTPCommand] -> IO [FTPResponse]
- getLineResp :: Handle -> IO ByteString
- getMultiLineResp :: Handle -> IO FTPResponse
- sendCommandLine :: Handle -> ByteString -> IO ()
- createDataSocket :: PortActivity -> Handle -> IO Socket
- createSendDataCommand :: Handle -> PortActivity -> [FTPCommand] -> IO Handle
- createTLSSendDataCommand :: Handle -> PortActivity -> [FTPCommand] -> IO Connection
Main Entrypoints
withFTP :: String -> Int -> (Handle -> FTPResponse -> IO a) -> IO a Source #
Takes a host name and port. A handle for interacting with the server
will be returned in a callback.
withFTP "ftp.server.com" 21 $ h welcome -> do
print welcome
login h "username" "password"
print =<< nlst h []
withFTPS :: String -> Int -> (Handle -> FTPResponse -> IO a) -> IO a Source #
Takes a host name and port. A handle for interacting with the server
will be returned in a callback. The commands will be protected with TLS.
Make sure to use TLS data commands like nlstS or retrS if you want
those to use TLS as well
withFTPS "ftps.server.com" 21 $ h welcome -> do
print welcome
login h "username" "password"
print =<< nlstS h []
Control Commands
Data Commands
Secure Data Commands
Types
data FTPCommand Source #
Commands according to the FTP specification
Constructors
| User String | |
| Pass String | |
| Acct String | |
| RType RTypeCode | |
| Retr String | |
| Nlst [String] | |
| Port HostAddress PortNumber | |
| Stor String | |
| List [String] | |
| Rnfr String | |
| Rnto String | |
| Dele String | |
| Size String | |
| Mkd String | |
| Rmd String | |
| Pbsz Int | |
| Prot ProtType | |
| Cwd String | |
| Cdup | |
| Ccc | |
| Auth | |
| Pwd | |
| Abor | |
| Pasv | |
| Quit |
Instances
data FTPResponse Source #
Response from an FTP command. ex "200 Welcome!"
Constructors
| FTPResponse | |
Fields
| |
Instances
data ResponseStatus Source #
First digit of an FTP response
Constructors
| Wait | 1 |
| Success | 2 |
| Continue | 3 |
| FailureRetry | 4 |
| Failure | 5 |
Instances
data PortActivity Source #
Can send and recieve a ByteString.
Constructors
| Handle | |
Fields
| |
Handle Implementations
sIOHandleImpl :: Handle -> Handle Source #
tlsHandleImpl :: Connection -> Handle Source #
Lower Level Functions
sendCommand :: Handle -> FTPCommand -> IO FTPResponse Source #
Send a command to the server and get a response back.
Some commands use a data Handle, and their data is not returned here.
sendCommands :: Handle -> [FTPCommand] -> IO [FTPResponse] Source #
Equvalent to > mapM . sendCommand
getLineResp :: Handle -> IO ByteString Source #
Get a line from the server
getMultiLineResp :: Handle -> IO FTPResponse Source #
Get a full response from the server
Used in sendCommand
sendCommandLine :: Handle -> ByteString -> IO () Source #
createDataSocket :: PortActivity -> Handle -> IO Socket Source #
Open a socket that can be used for data transfers
createSendDataCommand :: Handle -> PortActivity -> [FTPCommand] -> IO Handle Source #
Send setup commands to the server and
create a data Handle
createTLSSendDataCommand :: Handle -> PortActivity -> [FTPCommand] -> IO Connection Source #
Send setup commands to the server and create a data TLS connection