Organizational Research By

Surprising Reserch Topic

boostr.in 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();
    try
    {
        File dest = new File("../../public/images/new.png");
        Logger.debug("get destination: " + dest.getAbsolutePath() );
        file.renameTo(dest);
        return ok( file.getAbsolutePath() );
    }
    catch (Exception e)
    {
        e.printStackTrace();
        return ok(images.render(false, e.toString()));
    }
 
asked Sep 13, 2013 in Java Interview Questions by rajesh
edited Sep 12, 2013
0 votes
9 views



Related Hot Questions



Government Jobs Opening


...