private Attachment prepareAttachment( String fileName, String contentType, User user, byte[] contents, String tags) { System.out.println("prepare attachment of single file"); try { Attachment a = new Attachment(); a.setName(fileName); a.setMimeType(contentType); System.out.println("tryin to new File(DEFAULT_UPLOAD_DIRECTORY, user.getLogin());"); System.out.println("user = "******"user" + user.getId().toString()); System.out.println("root = " + root); root.mkdirs(); System.out.println("after rootmkdirs"); File tmpFile = File.createTempFile("upload_", ".bin", root); FileUtils.writeToFile(tmpFile, contents); a.setSize((long) contents.length); a.setMD5(FileUtils.getMD5(tmpFile)); a.setFileName("user" + user.getId() + "/" + tmpFile.getName()); return a; } catch (Exception ex) { System.out.println("exception occured : exc = " + ex); return null; } }