Get file from www or ftp

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Get file from www or ftp

Post by mol »

I wanna ask , if somebody know how to retrieve file from internet (maybe via www, so login and password is not required)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Get file from www or ftp

Post by Rathinagiri »

Yes, if we know the exact address of the file/directory.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Get file from www or ftp

Post by mol »

Of course, I know concrete adress and filename to retrieve.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Get file from www or ftp

Post by Rathinagiri »

Then you can get the file using a download manager like flashget or if you use firefox there are large number of extensions for downloading by giving the url.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Get file from www or ftp

Post by mol »

But....
I wanne build something like autoupdate - my program will test if there is new version on internet and - if newer exists - downloads it and run installation.

So, I need to download new setup file directly from my application - I've tested hyperlink - it works, but in this case user action is required...
User avatar
jrendon
Posts: 92
Joined: Thu Aug 14, 2008 9:21 pm

Re: Get file from www or ftp

Post by jrendon »

mol wrote:But....
I wanne build something like autoupdate - my program will test if there is new version on internet and - if newer exists - downloads it and run installation.

So, I need to download new setup file directly from my application - I've tested hyperlink - it works, but in this case user action is required...
I'm use wget for windows for update my program's with execute command on minimized window.

1.- with my update program execute the wget on minimized window and i get a file in txt
2.- I read the file txt and check the version on internet
3.- If the version is new then with wget download the new version on temp folder
4.- when the file is downloaded then close the main program and replace the new program.
5.- Listo ..... :mrgreen:

Regards
Juan Rendon

P.D. My english is bad, i need more practice. jejejeje
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Get file from www or ftp

Post by mol »

Thanks for your suggestion. I'll try to implement it tomorrow.
Marek
I want to renew this topic.
I think installing wget is not the best way...
It works, but - on each computer running my application I need to install wget - it's hard to realize.

Maybe another idea?

I watched for samples linked with MINIGUI Extended - FTPClient - but I don't know how to use it ("ftpclient" doesn't want to compile with Minigui Ext.)


Regards, Marek
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Get file from www or ftp

Post by mol »

Success!!!
Two days of searching ant testing and I've compiled from everything I found, small function that is really BIG! I wanna share it with us, maybe it will be useful!
I wanna put working example with this function.

Code: Select all

PROCEDURE DownloadFromWWW
	param cURL, cLocalFileName
	LOCAL oCon, oUrl, i

	cLocalFileName := alltrim(cLocalFileName)
	
   oUrl := tURL():New( cUrl )
   IF Empty( oUrl )
      MsgBox("Invalid url " + cUrl)
      return
   ENDIF

   IF oUrl:cProto != "http"
      MsgBox('This is a header test for http. Use an http address.')
      return
   END
   
   oCon := TipClientHttp():New( oUrl )
   oCon:nConnTimeout := 20000
   MsgBox("Connecting with "+ oUrl:cServer)
   IF oCon:Open( cUrl )

	MsgBox("Connection eshtablished." +chr(10)+"Press OK to retrieve" + oUrl:cPath +oUrl:cFile)
	oCon:WriteAll(cLocalFileName)
	MsgBox("Downloaded...")
    oCon:Close()
   ELSE
      MsgBox("Can't connect with "+ oUrl:cServer)
      IF oCon:SocketCon == NIL
         MsgBox("Connection not initiated")
      ELSEIF hb_InetErrorCode( oCon:SocketCon ) == 0
         MsgBox("Server sayed: "+ oCon:cReply)
      ELSE
         MsgBox("Error in connection: " + hb_InetErrorDesc( oCon:SocketCon ))
      ENDIF
   END
RETURN 
Attachments
download.zip
(2.26 KiB) Downloaded 428 times
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Get file from www or ftp

Post by esgici »

Hi Marek

Thanks to sharing :)

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Get file from www or ftp

Post by Rathinagiri »

Thanks a lot for sharing. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply