private static ContentProvider fileContentProvider(Path path) { try { PathContentProvider provider = new PathContentProvider(null, path); provider.setByteBufferPool(new ByteBufferPool() { @Override public ByteBuffer acquire(int size, boolean direct) { return ByteBuffer.allocate(size); } @Override public void release(ByteBuffer buffer) {} }); return provider; } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public boolean hasNext() { return position < getLength(); }
@Override public Request file(Path file, String contentType) throws IOException { return content(new PathContentProvider(contentType, file)); }
@Override public Request file(Path file, String contentType) throws IOException { if (contentType != null) header(HttpHeader.CONTENT_TYPE.asString(), contentType); return content(new PathContentProvider(file)); }
@Override public Request file(Path file, String contentType) throws IOException { if (contentType != null) header(HttpHeader.CONTENT_TYPE.asString(), contentType); return content(new PathContentProvider(file)); }
@Override public boolean hasNext() { return position < getLength(); }
@Override public boolean hasNext() { return position < getLength(); }