@Override public ITempFileManager create() { return new DefaultTempFileManager(); } }
private RandomAccessFile getTmpBucket() { try { ITempFile tempFile = this.tempFileManager.createTempFile(null); return new RandomAccessFile(tempFile.getName(), "rw"); } catch (Exception e) { throw new Error(e); // we won't recover, so throw an error } }
@Override public ITempFile createTempFile(String filename_hint) throws Exception { DefaultTempFile tempFile = new DefaultTempFile(this.tmpdir); this.tempFiles.add(tempFile); return tempFile; } }
@Override public void clear() { for (ITempFile file : this.tempFiles) { try { file.delete(); } catch (Exception ignored) { NanoHTTPD.LOG.log(Level.WARNING, "could not delete file ", ignored); } } this.tempFiles.clear(); }
@Override public ITempFile createTempFile(String filename_hint) throws Exception { DefaultTempFile tempFile = new DefaultTempFile(this.tmpdir); this.tempFiles.add(tempFile); System.out.println("Created tempFile: " + tempFile.getName()); return tempFile; } }
/** * Constructs an HTTP server on given hostname and port. */ public NanoHTTPD(String hostname, int port) { this.hostname = hostname; this.myPort = port; setTempFileManagerFactory(new DefaultTempFileManagerFactory()); setAsyncRunner(new DefaultAsyncRunner()); // creates a default handler that redirects to deprecated serve(); this.httpHandler = new IHandler<IHTTPSession, Response>() { @Override public Response handle(IHTTPSession input) { return NanoHTTPD.this.serve(input); } }; }
} finally { NanoHTTPD.safeClose(r); this.tempFileManager.clear();
/** * Retrieves the content of a sent file and saves it to a temporary file. * The full path to the saved file is returned. */ private String saveTmpFile(ByteBuffer b, int offset, int len, String filename_hint) { String path = ""; if (len > 0) { FileOutputStream fileOutputStream = null; try { ITempFile tempFile = this.tempFileManager.createTempFile(filename_hint); ByteBuffer src = b.duplicate(); fileOutputStream = new FileOutputStream(tempFile.getName()); FileChannel dest = fileOutputStream.getChannel(); src.position(offset).limit(offset + len); dest.write(src.slice()); path = tempFile.getName(); } catch (Exception e) { // Catch exception if any throw new Error(e); // we won't recover, so throw an error } finally { NanoHTTPD.safeClose(fileOutputStream); } } return path; }
@Override public void clear() { for (ITempFile file : this.tempFiles) { try { file.delete(); } catch (Exception ignored) { NanoHTTPD.LOG.log(Level.WARNING, "could not delete file ", ignored); } } this.tempFiles.clear(); }
@Override public ITempFile createTempFile(String filename_hint) throws Exception { DefaultTempFile tempFile = new DefaultTempFile(this.tmpdir); this.tempFiles.add(tempFile); return tempFile; } }
/** * Constructs an HTTP server on given hostname and port. */ public NanoHTTPD(String hostname, int port) { this.hostname = hostname; this.myPort = port; setTempFileManagerFactory(new DefaultTempFileManagerFactory()); setAsyncRunner(new DefaultAsyncRunner()); // creates a default handler that redirects to deprecated serve(); this.httpHandler = new IHandler<IHTTPSession, Response>() { @Override public Response handle(IHTTPSession input) { return NanoHTTPD.this.serve(input); } }; }
@Override public ITempFileManager create() { return new DefaultTempFileManager(); } }
private RandomAccessFile getTmpBucket() { try { ITempFile tempFile = this.tempFileManager.createTempFile(null); return new RandomAccessFile(tempFile.getName(), "rw"); } catch (Exception e) { throw new Error(e); // we won't recover, so throw an error } }
@Override public void clear() { for (ITempFile file : this.tempFiles) { try { file.delete(); } catch (Exception ignored) { NanoHTTPD.LOG.log(Level.WARNING, "could not delete file ", ignored); } } this.tempFiles.clear(); }
@Override public ITempFile createTempFile(String filename_hint) throws Exception { DefaultTempFile tempFile = new DefaultTempFile(this.tmpdir); this.tempFiles.add(tempFile); return tempFile; } }
/** * Constructs an HTTP server on given hostname and port. */ public NanoHTTPD(String hostname, int port) { this.hostname = hostname; this.myPort = port; setTempFileManagerFactory(new DefaultTempFileManagerFactory()); setAsyncRunner(new DefaultAsyncRunner()); // creates a default handler that redirects to deprecated serve(); this.httpHandler = new IHandler<IHTTPSession, Response>() { @Override public Response handle(IHTTPSession input) { return NanoHTTPD.this.serve(input); } }; }
@Override public ITempFileManager create() { return new DefaultTempFileManager(); } }
private RandomAccessFile getTmpBucket() { try { ITempFile tempFile = this.tempFileManager.createTempFile(null); return new RandomAccessFile(tempFile.getName(), "rw"); } catch (Exception e) { throw new Error(e); // we won't recover, so throw an error } }