mina-ftpserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Latorre <dvl...@gmail.com>
Subject Re: Is there a way to get the full underlying path of an uploaded fil in an Ftplet?
Date Wed, 02 Jun 2010 07:46:06 GMT
 You can cast the FTPFile to NativeFtpFile and use getPhysicalFile()
from there (although i guess you aren't able to do that in an OSGI
environment since NativeFtpFile should be internal).




2010/6/2 Roger Lee <rcleeny@gmail.com>:
> Here's what I did:
>
> String path = session.getUser().getHomeDirectory();
> FileSystemView fv = session.getFileSystemView();
> FtpFile wd = fv.getWorkingDirectory();
> path += wd.getAbsolutePath(); // / or /home/x/y
> path += "/";
> path += request.getArgument();
> // Make it into a system style path removes \\
> File f = new File(path);
> //now prefix with the full path
> path = f.getAbsolutePath();
> // finally get rid of that \. to clean it up
> path = path.replace("\\.\\", "\\");
> CriterCamMain.newJpgImage(path);
>
> Roger
>
> ----- Original Message ----- From: "Toli Kuznets"
> <tkuznets@marinsoftware.com>
> To: <ftpserver-users@mina.apache.org>
> Sent: Tuesday, June 01, 2010 10:02 PM
> Subject: Is there a way to get the full underlying path of an uploaded fil
> in an Ftplet?
>
>
>> Hi,
>>
>> I'm trying to write an Ftplet that performs a custom action on a file
>> after it gets uploaded in the onUploadEnd() method.
>>
>> I can get the current workingDir and the name of the file uploaded
>> from the session, but it doesn't seem that I can get the real
>> underlying pathname to that file.
>>
>> It exists in the session.getFileSystemView().rootDir variable, but
>> it's not expose - I can't seem to find an accessor for it. The
>> session.getFileSystemView().getFile(theFile) return an FtpFile, which
>> again doesn't expose the underlying path.
>>
>> Is there a way to get to that? I don't have a user object in the
>> FtpLet, so i can't lookup the user's homeDir.
>>
>> I can, of course, pass around my own object to the Ftplet constructor
>> that can do the username->homeDir lookup, but i was hoping to avoid
>> that.
>>
>> thanks.
>
>

Mime
View raw message