public Response makeResponse(FitNesseContext context, Request request) throws IOException {
rootPath = context.getRootPagePath();
SimpleResponse response = new SimpleResponse();
String resource = URLDecoder.decode(request.getResource(), "UTF-8");
final UploadedFile uploadedFile = (UploadedFile) request.getInput("file");
final String user = request.getAuthorizationUsername();
if (uploadedFile.isUsable()) {
final File file = makeFileToCreate(makeRelativeFilename(uploadedFile.getName()), resource);
if (!FileResponder.isInFilesDirectory(new File(rootPath), file)) {
return new ErrorResponder("Invalid path: " + uploadedFile.getName()).makeResponse(context, request);
}
context.versionsController.makeVersion(new FileVersion() {
@Override
public File getFile() {
return file;
}
@Override
public InputStream getContent() throws IOException {
return new BufferedInputStream(new FileInputStream(uploadedFile.getFile()) {
@Override
public void close() throws IOException {
super.close();
uploadedFile.getFile().delete();
}
});
}
@Override