Thank you very much for your fast reply.
For my purpose the good solution is to use onUploadStart() ftpLet method for
the first rename and onUploadEnd for the final one.
I tried to use the following method
public FtpletResult onUploadStart(FtpSession session, FtpRequest
request) throws FtpException, IOException {
System.out.println("==> Upload");
return FtpletResult.DEFAULT; }
I guessed I was been able to change the input file name using the FtpRequest
request, but this class/Interface provide only get method
(i.e. request.getArgument();)
How can I change the input file name? Is there another way to do it?I have the
same problem for the method onUploadEnd.Please, Could you send me an example?
Thank you in advance for your useful help.
Massimiliano.
--- Mar 12/5/09, David Latorre <[email protected]> ha scritto:
Da: David Latorre <[email protected]>
Oggetto: Re: STOR a temporary file
A: [email protected]
Data: Martedì 12 maggio 2009, 11:42
2009/5/12 massimiliano basilica <[email protected]>:
> HI all,
> I'm using FTPServer 1.0.I need that the FTPServer stores a file with a
> temporary file extention and rename it with originally file name.The
> scenario is:The Client sends the file "FirstFile.txt" (put FirstFile.txt).The
> FTPServer must store it as FirstFile.txt.tmp. When the uploading is
> completed, the FTPServer must rename it as FirstFile.txt.All must
> be transparent to the Client, it can't use the command
Hello massimiliano,
I have implemented something like that and it's kinda working but see
several potential problems:
- There's no way to know (at the server side) if the file has been
transferred correctly. When the data connection is closed, the server
thinks the file transfer finished correctly but this must not be the
case. Thus, the file could be renamed to it's final name even though
the connection was aborted -> you end up with an uncomplete file.
- Currently the onUploadEnd ftplet method will be executed after the
response to the client is sent. So if the file-rename fails the client
wouldn't know that anything happened. If this is a problem for you
(most likely) you should use your own STOR method. Otherwise, you can
use onUploadStart() ftpLet method for the first rename and onUploadEnd
for the final one.
Since we had this implemented before the change in ftpets what I did
is to provide my own STOR method which is an exact copy of Ftpserver's
implementation but adding a call to the "rename-to-.txt" method in
the Ftplet before the response is written to the session.
>
>
>
>
>
>
>