Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Jakarta common/net FTP - setRestartOffset - Upload Resume...

Reply
Thread Tools

Jakarta common/net FTP - setRestartOffset - Upload Resume...

 
 
KGuru
Guest
Posts: n/a
 
      03-22-2006
Hi all,

I have tried to understand how to resume an upload or download using
the FTPClient API from Jakarta common net libraries.

1- I started by uploading a file on the FTP server then I interupted
the upload in the middle (after for example 790000 bytes) :

FTPClient ftp=new FTPClient();
....
input = new FileInputStream("fileSourceName");
output = ftp.storeFileStream("fileTargetName");
....
Util.copyStream(input, output);

2- I restart the program but I have added a line of code that describe
an offset:

FTPClient ftp=new FTPClient();
ftp.setRestartOffset(790000);

3- I was expecting that the download will restart from the offset
instead the file upload starts from beginning...

a- In fact i checked the Util.copystream method, i cannot see any use
of the offset or is it simply handled by the FTP server?

b-I'm just wonderinfg thatif it is handled by the FTP server,
how does the FTP server knows where to start etc.. if the connection is
restarted...

c-if anyone has succesfully written the code that handles the "resume"
functionnality, it would be nice to see some code snippet.

Many Thanks!

 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      03-22-2006
KGuru wrote:
> a- In fact i checked the Util.copystream method, i cannot see any use
> of the offset or is it simply handled by the FTP server?
>
> b-I'm just wonderinfg thatif it is handled by the FTP server,
> how does the FTP server knows where to start etc.. if the connection is
> restarted...
>
> c-if anyone has succesfully written the code that handles the "resume"
> functionnality, it would be nice to see some code snippet.


Like always in such cases (maybe we should make a
mini-networking-debugging-FAQ out of this):

1) Sniff the network with a tool like Ethereal, snoop, or whatever to
see what is really going on on the network

2) Check the documentation of the server if and how it supports resuming
some transfer, and with which protocol (part).

3) Get a copy of the relevant RFC(s) to check if and how the protocol
should work and is actually used.

/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
http://www.uni-giessen.de/faq/archiv....java.gui.faq/
 
Reply With Quote
 
 
 
 
KGuru
Guest
Posts: n/a
 
      03-23-2006
Thanks fo your answer,

I was doing all the research and debug you are mentionning. I'm just
looking for someone who had experience the same type of problems and
how it was solved.

One discovery I made was that the FTP server was not supporting FTP
command such as : REST and SIZE command send by the API in order to
resume the upload.

Best regards
KGuru

 
Reply With Quote
 
KGuru
Guest
Posts: n/a
 
      03-23-2006
I think there is a bug in the common-net FTP Jakarta component, in the
Util package.


by adding the following line of code in the Util package in the
copyStream method:
try {
----->>> source.skip(offset); <<<<-----
while ((bytes = source.read(buffer)) != -1) {

the offset represents the size of the file on the server which is
returned by the following code (as i can't find the fileSize
method...): ftpfiles is returned by
ftp.initiateListParsing().getFiles().

for(int i=0; i<ftpFiles.length;i++){
if (ftpFiles[i].getName().equalsIgnoreCase(filename)){
return ftpFiles[i].getSize();
}
}

of course there was a need to set at the beginning og the code:
ftp.setRestartOffset(offset);


I'm not sure i'm clear ;> but I hope one has understood the logic. Is
there any better idea???

Br,
KGuru

 
Reply With Quote
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      03-23-2006
KGuru wrote:
> I was doing all the research and debug you are mentionning.


How should we know if you don't mention this in your first post?

> One discovery I made was that the FTP server was not supporting FTP
> command such as : REST and SIZE command send by the API in order to
> resume the upload.


So you know your answer: Use another FTP server.

/Thomas

--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
http://www.uni-giessen.de/faq/archiv....java.gui.faq/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lowongan : Web Programmer / Developer (Jakarta Raya Jakarta Pusat) untung Java 0 10-07-2009 01:22 PM
Secure FTP supported by Jakarta Commons Net? ht6554 Java 0 04-06-2006 08:29 PM
FTP connect problem with Jakarta Commons Net package Barry Java 1 01-15-2005 05:35 AM
[jakarta][FTP] progress bar transfert =?iso-8859-1?q?St=E9phane_KLEIN?= Java 1 10-05-2004 05:06 PM
Net::FTP problems getting files from Windows FTP server, but not Linux FTP Server. D. Buck Perl Misc 2 06-29-2004 02:05 PM



Advertisments