VoDA.FtpServer
1.0.0
VoDA.FtpServer는 간단한 FTP 서버 라이브러리입니다. 이 라이브러리는 이벤트 수준까지 FTP 프로토콜과의 상호 작용을 단순화합니다. 인증 또는 데이터 작업과 관련된 서버에 대한 모든 요청은 구현해야 하는 이벤트를 발생시킵니다.
서버를 시작하려면 FtpServerBuilder 개체를 만들고 아래 예제와 같이 함수를 사용하여 구성해야 합니다. 각 함수에 대한 자세한 내용은 ConfigurationParameters를 참조하세요. 구성 후 Build()
함수를 호출하여 서버를 생성합니다.
파일 시스템 작업을 위한 FTP 서버의 예는 테스트 프로젝트에 나와 있습니다.
var server = new FtpServerBuilder ( )
. ListenerSettings ( ( config ) =>
{
config . Port = 21 ; // enter the port
config . ServerIp = System . Net . IPAddress . Any ;
} )
. Log ( ( config ) =>
{
config . Level = LogLevel . Information ; // enter log level. Default: Information
} )
. Certificate ( ( config ) =>
{
config . CertificatePath = ". \ server.crt" ;
config . CertificateKey = ". \ server.key" ;
} )
. Authorization ( ( config ) =>
{
config . UseAuthorization = true ; // enable or disable authorization
config . UsernameVerification += ( username ) => { .. . } ; // username verification
config . PasswordVerification += ( username , password ) => { .. . } ; //verification of username and password
} )
. FileSystem ( ( fs ) =>
{
fs . OnDeleteFile += ( client , path ) => { .. . } ; // delete file event
fs . OnRename += ( client , from , to ) => { .. . } ; // rename item event
fs . OnDownload += ( client , path ) => { .. . } ; // download file event
fs . OnGetList += ( client , path ) => { .. . } ; // get items in folder event
fs . OnExistFile += ( client , path ) => { .. . } ; // file check event
fs . OnExistFoulder += ( client , path ) => { .. . } ; // folder check event
fs . OnCreate += ( client , path ) => { .. . } ; // file creation event
fs . OnAppend += ( client , path ) => { .. . } ; // append file event
fs . OnDeleteFolder += ( client , path ) => { .. . } ; // remove folder event
fs . OnUpload += ( client , path ) => { .. . } ; // upload file event
fs . OnGetFileSize += ( client , path ) => { .. . } ; // get file size event
fs . OnGetFileModificationTime += ( client , path ) => { .. . } ; // returns the last modified date of the file
} )
. Build ( ) ;
// Start FTP-serer
server . StartAsync ( System . Threading . CancellationToken . None ) . Wait ( ) ;
또는 컨텍스트 클래스에서 상속된 고유한 클래스를 사용할 수 있습니다. 예는 다음과 같습니다.
이 예에서 MyAuthorization
클래스는 VoDA.FtpServer.Contexts.AuthorizationOptionsContext
에서 상속되고 MyFileSystem
클래스는 VoDA.FtpServer.Contexts.FileSystemOptionsContext
에서 상속됩니다.
var server = new FtpServerBuilder ( )
. ListenerSettings ( ( config ) =>
{
config . Port = 21 ; // enter the port
config . ServerIp = System . Net . IPAddress . Any ;
} )
. Log ( ( config ) =>
{
config . Level = LogLevel . Information ; // enter log level. Default: Information
} )
. Certificate ( ( config ) =>
{
config . CertificatePath = ". \ server.crt" ;
config . CertificateKey = ". \ server.key" ;
} )
. Authorization < MyAuthorization > ( )
. FileSystem < MyFileSystem > ( )
. Build ( ) ;
// Start FTP-serer
server . StartAsync ( System . Threading . CancellationToken . None ) . Wait ( ) ;
전체 예제는 테스트 프로젝트를 참조하세요.