Recent

Author Topic: [SOLVED] Best FTP Library or Control or Class  (Read 11386 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1269
[SOLVED] Best FTP Library or Control or Class
« on: August 16, 2016, 08:05:07 pm »
For my first conversion project from VB.NET to Pascal
I have a simple FTP utility that uploads or downloads a CSS file to my website based on a simple Checkbox.

In .NET, I used FtpWebRequest. Set my credentials... it simply uses Streaming for the work.
Only 10-15 lines of code.

Is there a FTP "Uses" library included in Lazarus?, I don't see one.
How about a WinAPI? can I hook that up?

What is the easiest and best approach in Lazarus for FTP?

If I need to hook up a library or control I would like to find one that covers all aspects of FTP (upload/download files folders etc etc)
Of course, I would rather not use a control if I don't have to.

I did find several threads on this, but not sure which one is best.
I don't want to start off learning with improper coding

Thanks in Advance.
« Last Edit: August 20, 2016, 08:10:32 pm by technipixel »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

Fungus

  • Sr. Member
  • ****
  • Posts: 354
Re: Best FTP Library or Control or Class
« Reply #1 on: August 16, 2016, 08:35:06 pm »
Indy sockets might be what you need: http://www.indyproject.org/Sockets/index.EN.aspx

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Best FTP Library or Control or Class
« Reply #2 on: August 16, 2016, 08:43:29 pm »
Indy sockets might be what you need: http://www.indyproject.org/Sockets/index.EN.aspx

Okay... I will check it out.
Thanks
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Best FTP Library or Control or Class
« Reply #3 on: August 18, 2016, 04:08:03 am »
Okay... after trying all the suggested libraries (LNet, Indy, Synapse)
Getting any of them to work is ridiculous.
There old and finicky. Documentation is not really current.

In .NET it was so easy... just a few lines of code.

So, instead I want to know.

1) Can I call Winsock directly using just Win32.
2) Anyone suggest an inexpensive VCL (dll) that I can just call and use. (preferable with SSL)

I did find a couple of VCL's that handle FTP.
Emailed one company to see if it will work on Lazarus.

My little Utility is supposed to very simple.
I can't believe that LAZ doesn't have a built-in control with FTP included.

I mean, eventually, LNet, Indy and Synapse will become outdated... which they are already old.



Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Best FTP Library or Control or Class
« Reply #4 on: August 18, 2016, 04:20:08 am »
Do you absolutely need to use FTP? I can't recall the last time I needed to get something from an FTP server.

HTTP, HTTPS: use FPC's HTTP client to retrieve files. All of the files I need are retrieved that way.


mig-31

  • Sr. Member
  • ****
  • Posts: 308
Re: Best FTP Library or Control or Class
« Reply #5 on: August 18, 2016, 10:14:04 am »
All libraries LNet, Indy, Synapse are not old!!!

All libraries support ftp with ssl. You can find code examples in the package directory installation.

Example fo synapse
http://wiki.freepascal.org/Synapse

Using is not about number of lines, but if it work or not.

Show your code for ftp, where you have trouble.
« Last Edit: August 18, 2016, 10:15:57 am by mig-31 »
Lazarus 4.0 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

Thaddy

  • Hero Member
  • *****
  • Posts: 18728
  • To Europe: simply sell USA bonds: dollar collapses
Re: Best FTP Library or Control or Class
« Reply #6 on: August 18, 2016, 12:26:15 pm »
Apart from Phil being incorrect about ftp.
Maybe it is a good idea to start a wiki section about all the one liners  to 15 liners. I get fed up by this.
And answer by simply rtfm Ok, rtfw, maybe rtw.
To answer the question and ridicule c#:
Code: Pascal  [Select][+][-]
  1. function FtpGetFile(const IP, Port, FileName, LocalFile,
  2.   User, Pass: string): Boolean;

It is in ftpsend.pas. From synapse. As usual.
« Last Edit: August 18, 2016, 01:03:53 pm by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Best FTP Library or Control or Class
« Reply #7 on: August 18, 2016, 01:27:01 pm »
I cannot comment on indy but synapse and Lnet ak more than ok for blocking and async sockets.
you cannot tell thata synapse and lnet are outdated unless you agree that ftp itself is a pretty old and "outdated" protocol :)))
i'm using synapse ( a modification of it) on daily basis both for client and server apps ...
Speak postscript or die!
Translate to pdf and live!

JD

  • Hero Member
  • *****
  • Posts: 1909
Re: Best FTP Library or Control or Class
« Reply #8 on: August 18, 2016, 05:22:03 pm »
My little Utility is supposed to very simple.
I can't believe that LAZ doesn't have a built-in control with FTP included.

I mean, eventually, LNet, Indy and Synapse will become outdated... which they are already old.

Indy is regularly updated on https://indy.fulgan.com/ZIP/. Download the latest version from there. It has today's date as timestamp.

I just searched the forum and came up with 3 answers for you. The first link is to a utility I wrote a while ago to download a file from the internet using Indy HTTP. I still use a modified multithreaded version of it today to update client applications. The third link uses FTP.

All 3 are Indy based solutions.
 
So you have options. HTTP or FTP. :D

http://forum.lazarus.freepascal.org/index.php/topic,24565.msg147997.html#msg147997
http://forum.lazarus.freepascal.org/index.php/topic,11567.msg58098.html#msg58098
http://forum.lazarus.freepascal.org/index.php/topic,9715.msg47784.html#msg47784

JD
« Last Edit: August 18, 2016, 05:25:28 pm by JD »
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Best FTP Library or Control or Class
« Reply #9 on: August 18, 2016, 06:32:37 pm »
The utility that I already have built using .NET simply just downloads and uploads a CSS file.
And I used FTPWebRequest (from .NET) --- I want to convert this utility of LAZ.

I want to use a library that can work with all aspects of working with files located on a webserver.
FTP functions may be needed.

From all that I have read, a lot of people have problems getting the 3 major players to work properly (mainly installing)

And from my reading it seems that the Synapse gives me the best solutions for all web related things.

So, I go to this page... http://www.ararat.cz/synapse/doku.php/public:howto:installsynapse
And according to the installation guide I can place the Library in my projects "lib" folder and just call the "uses" i need.
Fine, was able to at least get the call to connect.

However, I want to make the Synapse library available for any and all projects I may use in the future.
So, according to the documentation on that page...

Quote
If you would like to configure your Lazarus IDE to be ready to use Synapse with all of your projects without having to copy the units to every single one of your project directories, then do this (Note: this was tested on Lazarus v0.9.12 BETA other versions are subject to change): First copy Synapse to any folder you wish (I have it in the components folder of Lazarus, but you can put it anywhere you like) then in the menu go to “Environment>CodeTools options” (Note: > means sub-menu). Then a small window will popup, when that happens there should be a textbox at the top that says “Aditional source search path for all projects” or something similiar to that. What you must do is insert the directory in which you have copied Synapse to. And there you have it. You are done. Enjoy using Synapse!

Okay... this documentation is old and doesn't apply to LAZ 1.6 (from what I can tell)
I don't see an "Environment/CodeTools" menu where I can add the library source to the "search path"

Where is this "add source to search path" in LAZ 1.6??



Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

wp

  • Hero Member
  • *****
  • Posts: 13349
Re: Best FTP Library or Control or Class
« Reply #10 on: August 18, 2016, 06:57:31 pm »
This is not the correct way to work with libraries. Yes, copy the synapse file to any folder you want to. But then open Lazarus, menu "Package", "Open Package File (.lpk)", navigate to the lpk files of the package - in case of synapse this is the laz_synapse.lpk. This opens the package editor. Just click "Compile". This is all because this package is a runtime package. Other libraries have components etc for installation into the IDE - in this case you must also click "Use" / "Install" which rebuilds the IDE and includes the new package (may take some time...)

In order to use the package in your program don't set any paths - you will end up in a mess. Just add the package to the requirements of the project: Open "Project" / "Project inspector" (in fact I have it open all the time because it helps to easily navigate to all project files). Right-click on "Required packages", "Add...", and enter the package name (laz_synapse) in the combobox "Package name", then "Create new requirement". Now your project will find all the synapse units used.

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Best FTP Library or Control or Class
« Reply #11 on: August 18, 2016, 07:06:09 pm »
This is not the correct way to work with libraries. Yes, copy the synapse file to any folder you want to. But then open Lazarus, menu "Package", "Open Package File (.lpk)", navigate to the lpk files of the package - in case of synapse this is the laz_synapse.lpk. This opens the package editor. Just click "Compile". This is all because this package is a runtime package. Other libraries have components etc for installation into the IDE - in this case you must also click "Use" / "Install" which rebuilds the IDE and includes the new package (may take some time...)

In order to use the package in your program don't set any paths - you will end up in a mess. Just add the package to the requirements of the project: Open "Project" / "Project inspector" (in fact I have it open all the time because it helps to easily navigate to all project files). Right-click on "Required packages", "Add...", and enter the package name (laz_synapse) in the combobox "Package name", then "Create new requirement". Now your project will find all the synapse units used.

Well... I was only going by the instructions on Synapse's page.
I can see why so many "Newbies" like myself ask so many question on this forum.

I find the documentation on a lot of LAZ, FreePascal and the wiki's to be either outdated or to complex, or leave off important information.
No wonder so many threads are full of confusion. (just sayin  ;)  )

I will give what you said a try... did this with INet, and got into all kinds of trouble compiling.
Geese, you would think this would be easier.... .NET is so much easier to plug stuff in.

Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Best FTP Library or Control or Class
« Reply #12 on: August 18, 2016, 07:14:09 pm »
Question...

Without re-compiling the IDE

Can I just include the .pas file I need in my project folder???
Or do I have to include the entire library if I want to just copy it to my project lib folder.
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

wp

  • Hero Member
  • *****
  • Posts: 13349
Re: Best FTP Library or Control or Class
« Reply #13 on: August 18, 2016, 07:35:43 pm »
I can understand that you are getting impatient, but it's like everywhere else: A wrong step in the beginning may lead you into nowhere.

There's probably too much crap lying around from your previous unsuccessful steps.  These issues can be resolved but it will be a lengthy process. The easiest and quickest way would be to go back and reinstall a clean Lazarus. You are on Windows - this is a really easy process. Make sure to check "secondary installation" in one of the first installation screens in order to leave your old installation alone. Then clean up the LNet directory from any compiler-generated files (or better: rename it to have a backup and prepare a new virgin LNet source folder). Compile the package - it will work.

Quote from: technipixel
Can I just include the .pas file I need in my project folder???
Or do I have to include the entire library if I want to just copy it to my project lib folder.
The package files are usually strongly interdependent, therefore the file you copy in the project folder will usually fail to find the other files it depends on. Just try. Or look at its "uses" lines to see the other files needed. Copying the entire library into the project folder will certainly work, you can skip demos, docs etc, it's a good idea to keep the folder structure. You'll have to add the paths to the "Other project files" box in the Project options in order to compile. The path is valid only in this particular project and should be fine. Don't check "Set compiler options" as default.

But: you were asking above for a solution to "make the Synapse library available for any and all projects I may use in the future." Copying the library into your project is just the opposite. You must compile the package to have the library available for all projects.

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: Best FTP Library or Control or Class
« Reply #14 on: August 18, 2016, 07:43:03 pm »
I understand the difference between including in just project or compiling for all.
I was just wondering if copying just necessary pas files would work. But I get the the fact the some pas files may call other pas files.

Even though my last INet compile failed, I was able to uninstall the failed package. So, the LAZ IDE compile is okay.
I don't think I have to re-install... everything seems to be working fine.

I may give the compile a retry

Thanks for clearing some things up.
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

 

TinyPortal © 2005-2018