On Mon, Aug 04, 2014 at 08:46:37PM -0400, Steve Kingsland wrote:
> Here is Kevin's example using PipedInputStream and PipedOutputStream:
> https://groups.google.com/d/msg/jclouds/F2pCt9i7TSg/AUF4AqOO0TMJ
> 
> I don't have the need to use different threads, though, so instead I'd do
> something like this?

This will not work; putBlob blocks until the operation completes.
Further you must use PipedInputStream/PipedOutputStream with separate
threads to avoid deadlock, as its Javadoc states:

http://docs.oracle.com/javase/7/docs/api/java/io/PipedInputStream.html

Unfortunately jclouds has poor support for asynchronous operations and
you can really only fake the desired behavior with various InputStream.
I strongly recommend trying to cast your solution into some kind of
ByteSource or InputStream.

> And then when close() or flush() is called on the returned OutputStream,
> the blob is uploaded like magic? Is it OK that I'm not setting the content
> length?

Some blobstores, specifically Amazon S3, require a content length, while
others such as OpenStack Swift do not.

-- 
Andrew Gaul
http://gaul.org/

Reply via email to