AZSBlobOutputStream Class Reference
Inherits from | NSOutputStream |
---|---|
Conforms to | NSStreamDelegate |
Declared in | AZSBlobOutputStream.h AZSBlobOutputStream.m |
Overview
An AZSBlobOutputStream is used to write data to a blob on the service.
The AZSBlobOutputStream class inherits from NSOutputStream, and is designed to be used similarly. To create an AZSBlobOutputStream instance, call the createOutputStream method on an instance of AZSCloudBlockBlob. Just like a regular output stream, you can set a delegate to be called on stream events, and then schedule the stream in a runloop. See https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Streams/Streams.html for more details about how to use streams.
Internally, the AZSBlobOutputStream will buffer data that’s written to it until it has buffered one block’s worth of data. (Currently, block size is hard-coded to 4 MB; this will soon be configurable.) That block will then be asynchronously committed to the service while more data is being buffered. To protect against usign too much network bandwidth at a time, there is a hard-coded maximum to how many uploads are outstanding at once (currently 3, this will soon be configurable.)
When close is called on the stream, the stream will commit any remaining data, and then commit the block list it has been building.
Warning: Using a AZSBlobOutputStream will overwrite any existing data in the blob.
Warning: The call to close the stream will block until all uploads are complete and the block list has been committed. As network operations, this make take a significant amount of time. Do not call close on a critical thread.
Bug: Currently, if there are too many outstanding block uploads, a call to write will block. This is a known issue.