[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 671
  • Last Modified:

Updating Textfile on FTP Server or HTTP Server

I need to use Indy components to update a file on the internet.
I will have a text file placed on a FTP server or HTTP Server (which ever method is the securist and/or easist to do). I would like my application to logon, check for existence of file and if its there, append some data to it. All the data will be in Comma delimited text (one string).

Can one one help me please?

Code please?
0
DelphiRulez
Asked:
DelphiRulez
  • 6
  • 3
  • 2
2 Solutions
 
JohnjcesCommented:
If you have Indy, why not download their example programs in which you will find a complete FTP client that will show you how to do pretty much everything you want to do.

You can get it at:

http://www.indyproject.org/Sockets/Demos/index.EN.aspx

Indy 9 demos have a link on that page as well as fewer demos for Indy 10.

John
0
 
DelphiRulezAuthor Commented:
I dont want a FTP Client! Connecting and uploading/downloading a file is not what i want to do. The file already exists there, i want to append to it. if there is code for that, then please find it and post it here.....
thanks for responding!
0
 
JohnjcesCommented:
Well... the file exists on the server that you want to change or rename or do something with, correct? This file resides on an HTTP server  or FTP server, correct?

Then you must have a client application that connects to your FTP server to get the file, change the file, delete the file and etc.

The demos also have an example of using Indy to grab a file off of an HTTP (web) server as I recall. Again this would be a client application.

In any event, your application will be a client.

The FTP client demo shows you how to use all of the IndyFTP components to do pretty much everything you want to do by your post using FTP, file transport protocol.

John

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JohnjcesCommented:
Oh... by learning from the demo on how to use the FTP components, you can piece this all together in your own custom application.
0
 
DelphiRulezAuthor Commented:
I already solved it on my own, using EE search results


See code below.....its just a segment of my actual code....but its working code incase others need it in the future

thanks for responding though

var
 F: TextFile;
begin
 if not idFTP.Connected then
 begin
  try
   idFTP.Connect;
   if IdFTP.Connected then
   begin
    idFTP.ChangeDIr('/public_ftp/cz/');
    IdFTP.Get('data.txt', 'data.txt', true, true);
    IdFTP.Delete('data.txt');
    AssignFile(F, 'data.txt');
    Append(F);
    WriteLn(F, GetPersonalInfo);
    CloseFile(F);
    IdFTP.Put('data.txt','data.txt',False);
    DeleteFile('data.txt');
   end
   else
    rchScreen.Lines.Add('Error connecting');
  finally
    IdFTP.Disconnect;
  end;
 end;
end;

Open in new window

0
 
Geert GruwezOracle dbaCommented:
try
  idFTP.Connect;

your try should be below the connect

idFTP.Connect;
try

only if you succeed in connecting need you disconnect

the other way means you allways disconnect, even if you couldn't connect
which may also produce an error

btw, your code is following the guidelines of Johnjces
0
 
DelphiRulezAuthor Commented:
already found and corrected it, after i posted last night....but thanks
0
 
DelphiRulezAuthor Commented:
"btw, your code is following the guidelines of Johnjces"

I believe I asked for code. "Code Please?"  Not a link to demos. I had already looked at demos and none of them did what i wanted them to do.

I knew how to connect and disconnect and get a list of files and get and put a file on a FTP server.

I just couldn't figure out how to update a file (Append) as my question stated.......and it all boiled down to the removal of the file, both on the server and the harddrive.

Sorry, but i solved it on my own. If I thought he deserved the points, i would happily give it to him....I have unlimited to go around....since I pay for the service.
0
 
Geert GruwezOracle dbaCommented:
sometimes a demo is enough, sometimes it's not
allways up to you to decide

it would off course be easier to open the file across the network and append data
this only works over VPN/WAN/LAN network, not FTP/HTTP

allthough i think it should be possible
as a file is sent in chunks across the ftp and then reassembled ...
0
 
DelphiRulezAuthor Commented:
thanks, but i needed it to work on either FTP or HTTP.  FTP seems to be doing the job!
0
 
DelphiRulezAuthor Commented:
I have decided to award the points to the two of you....becuase you two at least responded....and it should help someone else in the future.

Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now