How to access FTP read-only?

Post Reply
User avatar
Matheusfarias
Posts: 17
Joined: Mon Sep 10, 2012 1:55 pm
Location: João Pessoa/Paraiba/Brasil
Contact:

How to access FTP read-only?

Post by Matheusfarias »

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 | Expand

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 
ADutheil
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: How to access FTP read-only?

Post by ADutheil »

Did you try this:

Code: Select all | Expand

   oFTP              := tIPClientFtp():New( oUrl, file("c:\desenv.sys") )   oFTP:nConnTimeout := 20000   oFTP:bUsePasv     := .T.   oFTP:nAccessMode  := TIP_RO // #define TIP_RO 0 
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
User avatar
Matheusfarias
Posts: 17
Joined: Mon Sep 10, 2012 1:55 pm
Location: João Pessoa/Paraiba/Brasil
Contact:

Re: How to access FTP read-only?

Post by Matheusfarias »

ADutheil friend, not only that but tried several options how to manipulate the functions of the class dates yet unsuccessfully, to already put the class in the project build but still the changed value did not work.
Note: the value of DATA is changed but I can not access.
User avatar
Matheusfarias
Posts: 17
Joined: Mon Sep 10, 2012 1:55 pm
Location: João Pessoa/Paraiba/Brasil
Contact:

Re: How to access FTP read-only?

Post by Matheusfarias »

Hi all, I solved the problem by passing the instaciado parameter instead of cUrl object. Tip is. :D

Code: Select all | Expand

   cUrl      := "ftp://" + cUser + ":" + cPassword + "@" + cServer   oUrl              := tUrl():New( cUrl )   oFTP              := tIPClientFtp():New( oUrl, file("c:\desenv.sys") )   oFTP:nDefaultPort := 21   oFTP:nConnTimeout := 3000   oFTP:bUsePasv     := .T.   if At("@",cUrl)>0      oFTP:oUrl:cServer   := cServer      oFTP:oUrl:cUserID   := cUser      oFTP:oUrl:cPassword := cPassword   endif   IF oFTP:Open( oFTP:oUrl )      oFTP:oUrl:cPath := cRemoteDir      IF !oFtp:DownloadFile( cLocalFile,cRemoteFile )         lRetorno := .F.      ELSE         lRetorno := .t.      ENDIF      oFTP:Close()  Endif 
Post Reply