Sorry for posting this again but it was sorted as a reply to a different
topic....my fault
Hi,
I wonder what is the best way (security, convenience, ...) to write
files to a directory on the server. The directory also is used to serve
the files in a static way.
What I did up to now is attach a Directory to the router to serve static
files from a local directory. Now the question is how to proceed best so
that I can PUT or POST a new file exactly this local directory?
Here is my code for the server Component and the Application class:
public class MyServer extends Component {
public static void main(String[] args) throws Exception {
MyServer server = new MyServer();
server.start();
}
public MyServer() {
super();
this.getServers().add(Protocol.HTTP, 8180);
this.getClients().add(Protocol.FILE);
MyApplicationTUM(getContext().createChildContext()));
}
}
public class MyApplicationTUM extends Application {
public MyApplicationTUM(Context context) {
super();
setContext(context);
}
@Override
public Restlet createRoot() {
Router router = new Router(getContext());
String user_home = System.getProperty("user.home");
Directory fileRepository = new Directory(getContext(),
"file://"+user_home+"/serverFiles/");
fileRepository.setListingAllowed(true);
fileRepository.setModifiable(true);
fileRepository.setDeeplyAccessible(true);
router.attach("", MyIndexResourceTUM.class);
router.attach("/fileRepository", fileRepository);
return router;
}
}
I'd appreciate your help and/or suggestions,
Tobias
--
Dipl.-Bioinf. Tobias Girschick
Technische Universität München
Institut für Informatik
Lehrstuhl I12 - Bioinformatik
Bolzmannstr. 3
85748 Garching b. München, Germany
Room: MI 01.09.042
Phone: +49 (89) 289-18002
Email: [email protected]
Web: http://wwwkramer.in.tum.de/people/girschic
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381194