Any alternative to "OpenURL" for downloading file? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Michael Collier · 2014-01-29 10:19 My application needs to download files and save them locally before using them as part of an update procedure. The OpenURL command works ok for me, but it prompts the user for the location to save any downloaded files. I'd like to automate it so that the files are downloaded to a predefind location without user intervention. Can anyone suggest a way of doing this, either a subroutine/component/library? The files are held on a hosting company website so I can't install any server code. Thanks in advance.. ---------------------------------------------------------------------- chrnobel · 2014-01-29 11:41 If you are on at linux platform, you could use curl. This is an example for upload, but try to play around with curl from the command line, and then use the appropriate for downloading. Predefine a string like this; curlstring:='curl -X POST -F "filesToUpload=@/home/xxx/somedirectory/filename" URL-TO-UPLOADSERVER' fpsystem(curlstring); ---------------------------------------------------------------------- marcov · 2014-01-29 12:23 Curl is not guaranteed in base. E.g. in Debian it isn't always installed. ---------------------------------------------------------------------- BigChimp · 2014-01-29 12:30 Quote from: Michael Collier on January 29, 2014, 11:19:12 amI'd like to automate it so that the files are downloaded to a predefind location without user intervention. Can anyone suggest a way of doing this, either a subroutine/component/library? The files are held on a hosting company website so I can't install any server code. http://wiki.lazarus.freepascal.org/synapse#From_an_HTTP_server ---------------------------------------------------------------------- Timewarp · 2014-01-29 12:35 Easiest way for Windows is urlmon, example found in bugtracker 23107 ---------------------------------------------------------------------- Leledumbo · 2014-01-29 15:15 TFPHTTPClient anyone? It's cross platform and comes with FPC without any external dependencies. In trunk, you even have single line solution for simple requirements: Code: [Select]uses fphttpclient; ... TFPHTTPClient.SimpleGet('url','filepath to save result'); ... ---------------------------------------------------------------------- exdatis · 2014-01-29 15:42 Wow, great! ---------------------------------------------------------------------- marcov · 2014-01-29 15:43 Quote from: Leledumbo on January 29, 2014, 04:15:28 pmTFPHTTPClient anyone? It's cross platform and comes with FPC without any external dependencies. In trunk, you even have single line solution for simple requirements: Code: [Select]uses fphttpclient; ... TFPHTTPClient.SimpleGet('url','filepath to save result'); ... Afaik that fails on Windows machine that must mandatorily use a proxy (as many corporate desktops do). One of the advantages of using urlmon. ---------------------------------------------------------------------- Leledumbo · 2014-01-29 15:46 QuoteAfaik that fails on Windows machine that must mandatorily use a proxy (as many corporate desktops do). One of the advantages of using urlmon.Well, the OP doesn't say that the connection must be done through a proxy. In case it does, would you add such a feature, Marco? ---------------------------------------------------------------------- marcov · 2014-01-29 15:48 Quote from: Leledumbo on January 29, 2014, 04:46:23 pmQuoteAfaik that fails on Windows machine that must mandatorily use a proxy (as many corporate desktops do). One of the advantages of using urlmon.Well, the OP doesn't say that the connection must be done through a proxy. He also doesn't state that it is no problem to ignore a system wide configured proxy :-) QuoteIn case it does, would you add such a feature, Marco? I still have a partial own translation of urlmon, and when I have more time I'll see if I can combine those efforts and add it to winunits- base. ---------------------------------------------------------------------- BeniBela · 2014-01-29 22:21 Quote from: marcov on January 29, 2014, 04:43:43 pmAfaik that fails on Windows machine that must mandatorily use a proxy (as many corporate desktops do). One of the advantages of using urlmon. My Internet Tools use wininet, so they should also connect through the default proxy... Not intended for big files through