ExFTP.Storage.Common (ExFTP v1.0.4)

View Source

A module covering the low-level FTP responses

👀 See Also

📖 Resources

Summary

Types

A port/0 representing a temporary, negotiated passive socket to communicate with an FTP client.

Functions

Chunks a stream into chunk_size pieces for upload

Responds to FTP's CWD command

Responds to FTP's DELE command

Responds to FTP's LIST command

Responds to FTP's MKD command

Responds to FTP's NLST command

Takes a map and ensures the keys are atoms and use the correct conventions

Responds to FTP's PWD command

Responds to FTP's RETR command

Responds to FTP's RMD command

Responds to FTP's SIZE command

Responds to FTP's STOR command

Ensures you get a valid config according to a module, mod

Types

pasv_socket()

@type pasv_socket() :: port()

A port/0 representing a temporary, negotiated passive socket to communicate with an FTP client.

⚠️ Reminders

Sockets are everywhere

This socket represents a temporary TCP connection between the FTP Server and the client

While related, this passive socket is not the normal socket, which is often on port 21.

📖 Resources

Functions

chunk_stream(stream, opts)

Chunks a stream into chunk_size pieces for upload

🏷️ Params

cwd(server_state)

Responds to FTP's CWD command

RFC 959: CHANGE WORKING DIRECTORY (CWD)

This command allows the user to work with a different directory or dataset for file storage or retrieval without altering their login or accounting information. Transfer parameters are similarly unchanged. The argument is a pathname specifying a directory or other system dependent file group designator.

🏷️ Server State

👀 See Also

📖 Resources

dele(server_state)

Responds to FTP's DELE command

RFC 959: DELETE (DELE)

This command causes the file specified in the pathname to be deleted at the server site. If an extra level of protection is desired (such as the query, "Do you really wish to delete?"), it should be provided by the user-FTP process.

🏷️ Server State

👀 See Also

📖 Resources

list(server_state)

Responds to FTP's LIST command

RFC 959: LIST (LIST)

This command causes a list to be sent from the server to the passive DTP. If the pathname specifies a directory or other group of files, the server should transfer a list of files in the specified directory. If the pathname specifies a file then the server should send current information on the file. A null argument implies the user's current working or default directory. The data transfer is over the data connection in type ASCII or type EBCDIC. (The user must ensure that the TYPE is appropriately ASCII or EBCDIC). Since the information on a file may vary widely from system to system, this information may be hard to use automatically in a program, but may be quite useful to a human user.

🏷️ Server State

👀 See Also

📖 Resources

mkd(server_state)

Responds to FTP's MKD command

RFC 959: MAKE DIRECTORY (MKD)

This command causes the directory specified in the pathname to be created as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative).

🏷️ Server State

👀 See Also

📖 Resources

nlst(server_state)

Responds to FTP's NLST command

RFC 959: NAME LIST (NLST)

This command causes a directory listing to be sent from server to user site. The pathname should specify a directory or other system-specific file group descriptor; a null argument implies the current directory. The server will return a stream of names of files and no other information. The data will be transferred in ASCII or EBCDIC type over the data connection as valid pathname strings separated by <CRLF> or <NL>. (Again the user must ensure that the TYPE is correct.) This command is intended to return information that can be used by a program to further process the files automatically. For example, in the implementation of a "multiple get" function.

🏷️ Server State

👀 See Also

📖 Resources

prepare(m)

Takes a map and ensures the keys are atoms and use the correct conventions

pwd(server_state)

Responds to FTP's PWD command

RFC 959: PRINT WORKING DIRECTORY (PWD)

This command causes the name of the current working directory to be returned in the reply.

🏷️ Server State

👀 See Also

📖 Resources

retr(server_state)

Responds to FTP's RETR command

RFC 959: RETRIEVE (RETR)

This command causes the server-DTP to transfer a copy of the file, specified in the pathname, to the server- or user-DTP at the other end of the data connection. The status and contents of the file at the server site shall be unaffected.

🏷️ Server State

👀 See Also

📖 Resources

rmd(server_state)

Responds to FTP's RMD command

RFC 959: REMOVE DIRECTORY (RMD)

This command causes the directory specified in the pathname to be removed as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative).

🏷️ Server State

👀 See Also

📖 Resources

size(server_state)

Responds to FTP's SIZE command

RFC 3659: SIZE OF FILE (SIZE)

The FTP command, SIZE OF FILE (SIZE), is used to obtain the transfer size of a file from the server-FTP process. This is the exact number of octets (8 bit bytes) that would be transmitted over the data connection should that file be transmitted. This value will change depending on the current STRUcture, MODE, and TYPE of the data connection or of a data connection that would be created were one created now. Thus, the result of the SIZE command is dependent on the currently established STRU, MODE, and TYPE parameters.

The SIZE command returns how many octets would be transferred if the file were to be transferred using the current transfer structure, mode, and type. This command is normally used in conjunction with the RESTART (REST) command when STORing a file to a remote server in STREAM mode, to determine the restart point. The server-PI might need to read the partially transferred file, do any appropriate conversion, and count the number of octets that would be generated when sending the file in order to correctly respond to this command. Estimates of the file transfer size MUST NOT be returned; only precise information is acceptable.

🏷️ Server State

👀 See Also

📖 Resources

stor(server_state)

Responds to FTP's STOR command

RFC 959: STORE (STOR)

This command causes the server-DTP to accept the data transferred via the data connection and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist.

🏷️ Server State

👀 See Also

📖 Resources

validate_config(mod)

Ensures you get a valid config according to a module, mod