questions - Question:How to copy an uploaded file in Play Framework?


I'm trying to do a basic file upload in Play 2.0.4. The file upload itself works, and I manage to get a File object. However, I want to copy this file into the /public/images/ directory. How can I do that? The following code produces no result or errors:
    FilePart picture = body.getFile("file");
    File file = picture.getFile();
        File dest = new File("../../public/images/new.png");
        Logger.debug("get destination: " + dest.getAbsolutePath() );
        return ok( file.getAbsolutePath() );
    catch (Exception e)
        return ok(images.render(false, e.toString()));

asked Sep 13, 2013 in Java Interview Questions by rajesh
edited Sep 12, 2013
0 votes

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.