/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(resourceName), inline, fileMimeTypes); }
/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(resourceName), inline, fileMimeTypes); }
/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param filename The file name of the resource. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, String filename, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(filename), inline, fileMimeTypes); }
/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(resourceName), inline, fileMimeTypes); }
/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param filename The file name of the resource. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, String filename, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(filename), inline, fileMimeTypes); }
/** * Send the given resource from the given classloader. * * @param resourceName The path of the resource to load. * @param classLoader The classloader to load it from. * @param inline Whether it should be served as an inline file, or as an attachment. * @param filename The file name of the resource. * @param fileMimeTypes Used for file type mapping. * @return a '200 OK' result containing the resource in the body. */ public Result sendResource(String resourceName, ClassLoader classLoader, boolean inline, String filename, FileMimeTypes fileMimeTypes) { return doSendResource(StreamConverters.fromInputStream(() -> classLoader.getResourceAsStream(resourceName)), Optional.empty(), Optional.of(filename), inline, fileMimeTypes); }
/** * Send the given input stream. * * The input stream will be sent chunked since there is no specified content length. * * @param stream The input stream to send. * @return The result. */ public Result sendInputStream(InputStream stream) { if (stream == null) { throw new NullPointerException("Null stream"); } return new Result(status(), HttpEntity.chunked(StreamConverters.fromInputStream(() -> stream, DEFAULT_CHUNK_SIZE), Optional.empty())); }
/** * Send the given input stream. * * The input stream will be sent chunked since there is no specified content length. * * @param stream The input stream to send. * @return The result. */ public Result sendInputStream(InputStream stream) { if (stream == null) { throw new NullPointerException("Null stream"); } return new Result(status(), HttpEntity.chunked(StreamConverters.fromInputStream(() -> stream, DEFAULT_CHUNK_SIZE), Optional.empty())); }
/** * Send the given input stream. * * The input stream will be sent chunked since there is no specified content length. * * @param stream The input stream to send. * @return The result. */ public Result sendInputStream(InputStream stream) { if (stream == null) { throw new NullPointerException("Null stream"); } return new Result(status(), HttpEntity.chunked(StreamConverters.fromInputStream(() -> stream, DEFAULT_CHUNK_SIZE), Optional.empty())); }
/** * Send the given input stream. * * @param stream The input stream to send. * @param contentLength The length of the content in the stream. * @return The result. */ public Result sendInputStream(InputStream stream, long contentLength) { if (stream == null) { throw new NullPointerException("Null stream"); } return new Result(status(), new HttpEntity.Streamed(StreamConverters.fromInputStream(() -> stream, DEFAULT_CHUNK_SIZE), Optional.of(contentLength), Optional.empty())); }
/** * Send the given input stream. * * @param stream The input stream to send. * @param contentLength The length of the content in the stream. * @return The result. */ public Result sendInputStream(InputStream stream, long contentLength) { if (stream == null) { throw new NullPointerException("Null stream"); } return new Result(status(), new HttpEntity.Streamed(StreamConverters.fromInputStream(() -> stream, DEFAULT_CHUNK_SIZE), Optional.of(contentLength), Optional.empty())); }
/** * Send the given input stream. * * @param stream The input stream to send. * @param contentLength The length of the content in the stream. * @return The result. */ public Result sendInputStream(InputStream stream, long contentLength) { if (stream == null) { throw new NullPointerException("Null stream"); } return new Result(status(), new HttpEntity.Streamed(StreamConverters.fromInputStream(() -> stream, DEFAULT_CHUNK_SIZE), Optional.of(contentLength), Optional.empty())); }
/** * Creates a {@link SourceBodyWritable}, setting the content-type to "application/octet-stream". * * @param is the inputstream * @return a {@link SourceBodyWritable} instance. */ default BodyWritable<Source<ByteString, ?>> body(Supplier<InputStream> is) { return new SourceBodyWritable(StreamConverters.fromInputStream(is::get)); }
/** * Creates a {@link SourceBodyWritable}, setting the content-type to "application/octet-stream". * * @param is the inputstream * @return a {@link SourceBodyWritable} instance. */ default BodyWritable<Source<ByteString, ?>> body(Supplier<InputStream> is) { return new SourceBodyWritable(StreamConverters.fromInputStream(is::get)); }