question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offer a way to create and return OutputStreams

See original GitHub issue

Right now it looks like the SDK only accepts input streams which results in extra boilerplate in application code looking to write data by streaming it rather than holding it in memory.

The Azure blob storage APIs offer something along these lines via a method called blobOutputStream. Basically all metadata is prepared up front and then a method is called to return a stream.

That stream can then be passed back to the caller.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
lnnwvrcommented, Sep 6, 2020

Here we go… something like

import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.Future;

public class S3FutureOutputStream extends OutputStream {

  private final OutputStream wrapped;
  private final Future<?> future;

  public S3FutureOutputStream(OutputStream outputStream, Future<?> future) {
    wrapped = outputStream;
    this.future = future;
  }

  @Override
  public void write(int b) throws IOException {
    wrapped.write(b);
  }

  @Override
  public void write(byte[] b) throws IOException {
    wrapped.write(b);
  }

  @Override
  public void write(byte[] b, int off, int len) throws IOException {
    wrapped.write(b, off, len);
  }

  @Override
  public void flush() throws IOException {
    wrapped.flush();
  }

  @Override
  public void close() throws IOException {
    wrapped.close();
    try {
      future.get();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

1reaction
balamuruganacommented, May 27, 2020

Thanks. We will check the possibility.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guide to Java OutputStream | Baeldung
In this tutorial, we'll explore details about the Java class OutputStream. OutputStream is an abstract class. This serves as the superclass ...
Read more >
10 Ways to Create a Stream in Java - GeeksforGeeks
Output : Geeks for Geeks. Create a stream from specified values ... This method returns a sequential Stream containing the t elements.
Read more >
about Output Streams - PowerShell - Microsoft Learn
Explains the availability and purpose of output streams in PowerShell. ... The streams provide channels for different types of messages.
Read more >
Why, when and how to return Stream from your Java API ...
We use Stream. generate() method to build an infinite stream (7), where each element is created by the provided supplier. At this point,...
Read more >
OutputStream (Java Platform SE 8 ) - Oracle Help Center
Applications that need to define a subclass of OutputStream must always provide at least a method that writes one byte of output.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found