Skip to content

Instantly share code, notes, and snippets.

@ivanursul
Created April 6, 2016 11:19
Show Gist options
  • Save ivanursul/f46713f6934301bf8e17b058eea3f5bb to your computer and use it in GitHub Desktop.
Save ivanursul/f46713f6934301bf8e17b058eea3f5bb to your computer and use it in GitHub Desktop.
public static ImageStreamWrapper getStreamWrapper(Supplier<FormDataBodyPart> supplier) {
return Optional.ofNullable(supplier.get())
.map(field -> {
InputStream is = field.getValueAs(InputStream.class);
long contentLength = getContentLength(field);
return new ImageStreamWrapper(is, contentLength);
}).orElse(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment