ftp

package module
v0.0.0-...-524c80e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2015 License: ISC Imports: 10 Imported by: 0

README

goftp

FTP client golang package based on initial version of https://github.com/jlaffaye/goftp

To install do :

$ go get -u github.com/LDCS/goftp

Documentation

Index

Constants

View Source
const (
	// Positive Preliminary reply
	StatusInitiating    = 100
	StatusRestartMarker = 110
	StatusReadyMinute   = 120
	StatusAlreadyOpen   = 125
	StatusAboutToSend   = 150

	// Positive Completion reply
	StatusCommandOK             = 200
	StatusCommandNotImplemented = 202
	StatusSystem                = 211
	StatusDirectory             = 212
	StatusFile                  = 213
	StatusHelp                  = 214
	StatusName                  = 215
	StatusReady                 = 220
	StatusClosing               = 221
	StatusDataConnectionOpen    = 225
	StatusClosingDataConnection = 226
	StatusPassiveMode           = 227
	StatusLongPassiveMode       = 228
	StatusExtendedPassiveMode   = 229
	StatusLoggedIn              = 230
	StatusLoggedOut             = 231
	StatusLogoutAck             = 232
	StatusRequestedFileActionOK = 250
	StatusPathCreated           = 257

	// Positive Intermediate reply
	StatusUserOK             = 331
	StatusLoginNeedAccount   = 332
	StatusRequestFilePending = 350

	// Transient Negative Completion reply
	StatusNotAvailable             = 421
	StatusCanNotOpenDataConnection = 425
	StatusTransfertAborted         = 426
	StatusInvalidCredentials       = 430
	StatusHostUnavailable          = 434
	StatusFileActionIgnored        = 450
	StatusActionAborted            = 451
	Status452                      = 452

	// Permanent Negative Completion reply
	StatusBadCommand              = 500
	StatusBadArguments            = 501
	StatusNotImplemented          = 502
	StatusBadSequence             = 503
	StatusNotImplementedParameter = 504
	StatusNotLoggedIn             = 530
	StatusStorNeedAccount         = 532
	StatusFileUnavailable         = 550
	StatusPageTypeUnknown         = 551
	StatusExceededStorage         = 552
	StatusBadFileName             = 553
)

Variables

View Source
var MONTHS []string = []string{"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"}

Functions

This section is empty.

Types

type FTPListData

type FTPListData struct {
	RawLine   string
	Name      string
	TryCwd    bool
	TryRetr   bool
	Size      uint64
	MtimeType MTIME_TYPE
	Mtime     time.Time
	IdType    ID_TYPE
	Id        string
	LinkDest  string
}
ParseLine() function returns an

instance of this struct, capturing the parsed data.

:IVariables:

name : str The name of the file, if parsable

try_cwd : bool “true“ if the entry might be a directory (i.e., the caller might want to try an FTP “CWD“ command), “false“ if it

cannot possibly be a directory.

try_retr : bool “true“ if the entry might be a retrievable file (i.e., the caller might want to try an FTP “RETR“ command), “false“ if it

cannot possibly be a file.

size : long The file's size, in bytes

mtime : Time The file's modification time.

mtime_type : `MTIME_TYPE`

How to interpret the modification time. See `MTIME_TYPE`.

id : str

A unique identifier for the file. The unique identifier is unique

on the *server*. On a Unix system, this identifier might be the device number and the file's inode; on other system's, it might

be something else. It's also possible for this field to be ``nil``.

id_type : `ID_TYPE`

link_dest : Link destination when listing is a link

func ParseLine

func ParseLine(ftpListLine string) (fdata *FTPListData)

type ID_TYPE

type ID_TYPE int
const (
	UNKNOWN_ID_TYPE ID_TYPE = iota
	FULL_ID_TYPE
)

type MTIME_TYPE

type MTIME_TYPE int
const (
	UNKNOWN_MTIME_TYPE MTIME_TYPE = iota
	LOCAL_MTIME_TYPE
	REMOTE_MINUTE_MTIME_TYPE
	REMOTE_DAY_MTIME_TYPE
)

type ServerConn

type ServerConn struct {
	// contains filtered or unexported fields
}

func Connect

func Connect(addr string, timeout_duration time.Duration) (*ServerConn, error)

Connect to a ftp server and returns a ServerConn handler.

func (*ServerConn) ChangeDir

func (c *ServerConn) ChangeDir(path string) error

Changes the current directory to the specified path.

func (*ServerConn) ChangeDirToParent

func (c *ServerConn) ChangeDirToParent() error

Changes the current directory to the parent directory. ChangeDir("..")

func (*ServerConn) CurrentDir

func (c *ServerConn) CurrentDir() (string, error)

Returns the path of the current directory.

func (*ServerConn) Delete

func (c *ServerConn) Delete(path string) error

Deletes a file on the remote FTP server.

func (*ServerConn) List

func (c *ServerConn) List(path string) (entries []*FTPListData, err error)

func (*ServerConn) Login

func (c *ServerConn) Login(user, password string) error

func (*ServerConn) MakeDir

func (c *ServerConn) MakeDir(path string) error

Creates a new directory on the remote FTP server.

func (*ServerConn) NoOp

func (c *ServerConn) NoOp() error

Sends a NOOP command. Usualy used to prevent timeouts.

func (*ServerConn) Quit

func (c *ServerConn) Quit() error

Properly close the connection from the remote FTP server. It notifies the remote server that we are about to close the connection, then it really closes it.

func (*ServerConn) RemoveDir

func (c *ServerConn) RemoveDir(path string) error

Removes a directory from the remote FTP server.

func (*ServerConn) Rename

func (c *ServerConn) Rename(from, to string) error

Renames a file on the remote FTP server.

func (*ServerConn) Retr

func (c *ServerConn) Retr(path string) (io.ReadCloser, error)

Retrieves a file from the remote FTP server. The ReadCloser must be closed at the end of the operation.

func (*ServerConn) SetReadTimeoutFlag

func (c *ServerConn) SetReadTimeoutFlag()

func (*ServerConn) Stor

func (c *ServerConn) Stor(path string, r io.Reader) error

Uploads a file to the remote FTP server. This function gets the data from the io.Reader. Hint: io.Pipe()

func (*ServerConn) UnsetReadTimeoutFlag

func (c *ServerConn) UnsetReadTimeoutFlag()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL