How to access FTP read-only?
Posted: Thu Nov 21, 2013 7:20 pm
Hello guys, I'm using the classes of xHarbour to manage the movements of my FTP programa.I Have a client that uses a third party service (FTP) access ,is read-only and class access is Read and Write (:: nAccessMode: = TIP_RW / / a read-write protocol), I tried to modify all forms, could not, anyone have any idea?Follows the part of the Code:
Code: Select all
Function FtpDownload(cServer,cUser,cPassword,cRemoteFile,cLocalFile,cRemoteDir)
Local oUrl , cUrl , oFtp , cStr , lRetorno
Default cServer:="",cUser:="",cPassword:="",cRemoteFile:="",cRemoteDir:=""
if Empty(cServer)
msgAlert("Atenção Host não informado!","Alerta")
return .f.
endif
if Empty(cUser)
msgAlert("Atenção Usuario não informado!","Alerta")
return .f.
endif
if Empty(cPassword)
msgAlert("Atenção Senha não informado!","Alerta")
return .f.
endif
if Empty(cRemoteFile)
msgAlert("Atenção Arquivo não informado!","Alerta")
return .f.
endif
if !isConnected()
msgAlert("Atenção Sem Conexão com a Internet!","Alerta")
return .f.
endif
cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer
oUrl := tUrl():New( cUrl )
oFTP := tIPClientFtp():New( oUrl, file("c:\desenv.sys") )
oFTP:nConnTimeout := 20000
oFTP:bUsePasv := .T.
IF At( "@", cUser ) > 0
oFTP:oUrl:cServer := cServer
oFTP:oUrl:cUserID := cUser
oFTP:oUrl:cPassword := cPassword
ENDIF
IF oFTP:Open( cUrl )
oFTP:oUrl:cPath := cRemoteDir
IF !oFtp:DownloadFile( cLocalFile+cRemoteFile,cRemoteFile )
lRetorno := .F.
ELSE
lRetorno := .t.
ENDIF
oFTP:Close()
ELSE
cStr := "Não foi possivel conectar ao Ftp:" + oURL:cServer
IF oFTP:SocketCon == NIL
cStr += Chr( 13 ) + Chr( 10 ) + "Conexão não iniciada!"
ELSEIF InetErrorCode( oFTP:SocketCon ) == 0
cStr += Chr( 13 ) + Chr( 10 ) + "Resposta do Servidor:" + " " + oFTP:cReply
ELSE
cStr += Chr( 13 ) + Chr( 10 ) + "Erro na Conexão:" + " " + InetErrorDesc( oFTP:SocketCon )
ENDIF
msgstop(cStr,"Erro")
lRetorno:=.f.
ENDIF
RETURN lRetorno