Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input stream #1

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
69A278081C24A6A000981FF0 /* AZSAccountSasTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A278071C24A6A000981FF0 /* AZSAccountSasTests.m */; };
69BE84101C223F2B00AF170E /* AZSIPRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 69BE840E1C223F2B00AF170E /* AZSIPRange.h */; settings = {ATTRIBUTES = (Public, ); }; };
69BE84111C223F2B00AF170E /* AZSIPRange.m in Sources */ = {isa = PBXBuildFile; fileRef = 69BE840F1C223F2B00AF170E /* AZSIPRange.m */; };
69F68DAE1C653EA70056D9E3 /* AZSStreamDownloadBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F68DAD1C653EA70056D9E3 /* AZSStreamDownloadBuffer.h */; };
69F68DB01C653F3F0056D9E3 /* AZSStreamDownloadBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 69F68DAF1C653F3F0056D9E3 /* AZSStreamDownloadBuffer.m */; };
69F68DB21C6550C10056D9E3 /* AZSBlobInputStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F68DB11C6550C10056D9E3 /* AZSBlobInputStream.h */; };
69F68DB41C6942330056D9E3 /* AZSBlobInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 69F68DB31C6942330056D9E3 /* AZSBlobInputStream.m */; };
69FF6EBF1B83C56200AF4FDE /* AZSLeaseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69FF6EBE1B83C56200AF4FDE /* AZSLeaseTests.m */; };
B01734011B0A59BE00E5807C /* AZSCloudBlob.m in Sources */ = {isa = PBXBuildFile; fileRef = B01734001B0A59BE00E5807C /* AZSCloudBlob.m */; };
B01734041B0B04A500E5807C /* AZSBlobRequestXML.m in Sources */ = {isa = PBXBuildFile; fileRef = B01734031B0B04A500E5807C /* AZSBlobRequestXML.m */; };
Expand Down Expand Up @@ -81,7 +85,7 @@
B05A0E801B126592005DCF06 /* AZSCloudBlockBlobTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B05A0E7F1B126592005DCF06 /* AZSCloudBlockBlobTests.m */; };
B05DEAF81AF006A30023B955 /* AZSBlobRequestOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = B05DEAF71AF006A30023B955 /* AZSBlobRequestOptions.m */; };
B05EC6E01B27F47F0048EDD4 /* AZSBlobOutputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = B05EC6DF1B27F47F0048EDD4 /* AZSBlobOutputStream.m */; };
B05EC6E21B28E63F0048EDD4 /* AZSBlobOutputStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B05EC6E11B28E63F0048EDD4 /* AZSBlobOutputStreamTests.m */; };
B05EC6E21B28E63F0048EDD4 /* AZSBlobStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B05EC6E11B28E63F0048EDD4 /* AZSBlobStreamTests.m */; };
B06CA9E81B748083001B7303 /* AZSTestRetry.m in Sources */ = {isa = PBXBuildFile; fileRef = B06CA9E71B748083001B7303 /* AZSTestRetry.m */; };
B07ED56D1AE6CE6A0012E8C1 /* AZSBlobRequestFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = B07ED56C1AE6CE6A0012E8C1 /* AZSBlobRequestFactory.m */; };
B07ED57E1AE829FC0012E8C1 /* AZSSharedKeyBlobAuthenticationHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = B07ED57D1AE829FC0012E8C1 /* AZSSharedKeyBlobAuthenticationHandler.m */; };
Expand Down Expand Up @@ -189,6 +193,10 @@
69A278071C24A6A000981FF0 /* AZSAccountSasTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSAccountSasTests.m; sourceTree = "<group>"; };
69BE840E1C223F2B00AF170E /* AZSIPRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AZSIPRange.h; sourceTree = "<group>"; };
69BE840F1C223F2B00AF170E /* AZSIPRange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSIPRange.m; sourceTree = "<group>"; };
69F68DAD1C653EA70056D9E3 /* AZSStreamDownloadBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AZSStreamDownloadBuffer.h; sourceTree = "<group>"; };
69F68DAF1C653F3F0056D9E3 /* AZSStreamDownloadBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSStreamDownloadBuffer.m; sourceTree = "<group>"; };
69F68DB11C6550C10056D9E3 /* AZSBlobInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AZSBlobInputStream.h; sourceTree = "<group>"; };
69F68DB31C6942330056D9E3 /* AZSBlobInputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSBlobInputStream.m; sourceTree = "<group>"; };
69FF6EBE1B83C56200AF4FDE /* AZSLeaseTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSLeaseTests.m; sourceTree = "<group>"; };
B01733FF1B0A59BE00E5807C /* AZSCloudBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AZSCloudBlob.h; sourceTree = "<group>"; };
B01734001B0A59BE00E5807C /* AZSCloudBlob.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSCloudBlob.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -245,7 +253,7 @@
B05DEAF71AF006A30023B955 /* AZSBlobRequestOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSBlobRequestOptions.m; sourceTree = "<group>"; };
B05EC6DE1B27F47F0048EDD4 /* AZSBlobOutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AZSBlobOutputStream.h; sourceTree = "<group>"; };
B05EC6DF1B27F47F0048EDD4 /* AZSBlobOutputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSBlobOutputStream.m; sourceTree = "<group>"; };
B05EC6E11B28E63F0048EDD4 /* AZSBlobOutputStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSBlobOutputStreamTests.m; sourceTree = "<group>"; };
B05EC6E11B28E63F0048EDD4 /* AZSBlobStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSBlobStreamTests.m; sourceTree = "<group>"; };
B06CA9E71B748083001B7303 /* AZSTestRetry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSTestRetry.m; sourceTree = "<group>"; };
B07ED56B1AE6CE6A0012E8C1 /* AZSBlobRequestFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AZSBlobRequestFactory.h; sourceTree = "<group>"; };
B07ED56C1AE6CE6A0012E8C1 /* AZSBlobRequestFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AZSBlobRequestFactory.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -329,6 +337,21 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
953A1AC11ECA7AAF005C57E2 /* ServiceProperties */ = {
isa = PBXGroup;
children = (
57E472281DF73E7000B343AB /* AZSServiceProperties.m */,
57E4722A1DF7423A00B343AB /* AZSServiceProperties.h */,
57F37C011E1F09BB00FF130F /* AZSLoggingProperties.h */,
57F37C021E1F1D3400FF130F /* AZSMetricsProperties.h */,
57F37C031E1F290A00FF130F /* AZSLoggingProperties.m */,
57F37C051E1F292800FF130F /* AZSMetricsProperties.m */,
57F37C0A1E2022B900FF130F /* AZSCorsRule.h */,
57F37C0B1E2022D300FF130F /* AZSCorsRule.m */,
);
name = ServiceProperties;
sourceTree = "<group>";
};
B01AF6021AE0718F009A2022 /* Blob */ = {
isa = PBXGroup;
children = (
Expand All @@ -338,14 +361,12 @@
B09BDEA61C1A4787004D2F94 /* AZSCloudBlobDirectory.m */,
B01AF5F31AE06DDC009A2022 /* AZSCloudBlobClient.h */,
B01AF5F41AE06DDC009A2022 /* AZSCloudBlobClient.m */,
BE4510691A9D254600C3F971 /* AZSCloudBlockBlob.h */,
BE45106A1A9D254600C3F971 /* AZSCloudBlockBlob.m */,
B01AF5F01AE053BE009A2022 /* AZSCloudBlobContainer.h */,
B01AF5F11AE053BE009A2022 /* AZSCloudBlobContainer.m */,
B05DEAF61AF006A30023B955 /* AZSBlobRequestOptions.h */,
B05DEAF71AF006A30023B955 /* AZSBlobRequestOptions.m */,
B01733FF1B0A59BE00E5807C /* AZSCloudBlob.h */,
B01734001B0A59BE00E5807C /* AZSCloudBlob.m */,
B05DEAF61AF006A30023B955 /* AZSBlobRequestOptions.h */,
B05DEAF71AF006A30023B955 /* AZSBlobRequestOptions.m */,
B05A0E6F1B0BF308005DCF06 /* AZSBlockListItem.h */,
B05A0E701B0BF308005DCF06 /* AZSBlockListItem.m */,
BE7E3E4D1B165F6F00BC96B6 /* AZSBlobContainerProperties.h */,
Expand All @@ -354,10 +375,14 @@
BE7E3E521B18D80A00BC96B6 /* AZSBlobProperties.m */,
BE7E3E551B18D82100BC96B6 /* AZSCopyState.h */,
BE7E3E561B18D82100BC96B6 /* AZSCopyState.m */,
69F68DB11C6550C10056D9E3 /* AZSBlobInputStream.h */,
69F68DB31C6942330056D9E3 /* AZSBlobInputStream.m */,
B05EC6DE1B27F47F0048EDD4 /* AZSBlobOutputStream.h */,
B05EC6DF1B27F47F0048EDD4 /* AZSBlobOutputStream.m */,
B058A4951B55628700BB0F57 /* AZSBlobUploadHelper.h */,
B058A4961B55628700BB0F57 /* AZSBlobUploadHelper.m */,
BE4510691A9D254600C3F971 /* AZSCloudBlockBlob.h */,
BE45106A1A9D254600C3F971 /* AZSCloudBlockBlob.m */,
B0DD6B5E1C208105004B3A7D /* AZSCloudPageBlob.h */,
B0DD6B5F1C208105004B3A7D /* AZSCloudPageBlob.m */,
B0DD6B641C209175004B3A7D /* AZSCloudAppendBlob.h */,
Expand Down Expand Up @@ -396,6 +421,8 @@
B01AF60F1AE098CB009A2022 /* AZSExecutor.m */,
B01AF6111AE099C5009A2022 /* AZSRequestOptions.h */,
B01AF6121AE099C5009A2022 /* AZSRequestOptions.m */,
69F68DAD1C653EA70056D9E3 /* AZSStreamDownloadBuffer.h */,
69F68DAF1C653F3F0056D9E3 /* AZSStreamDownloadBuffer.m */,
);
name = Executor;
sourceTree = "<group>";
Expand Down Expand Up @@ -446,6 +473,7 @@
BE4510451A9D252300C3F971 /* AZSClient */ = {
isa = PBXGroup;
children = (
953A1AC11ECA7AAF005C57E2 /* ServiceProperties */,
BEC4476D1B751FBA00111ADA /* Constants */,
B07ED56E1AE713CA0012E8C1 /* Auth */,
B01AF6041AE08C50009A2022 /* Executor */,
Expand Down Expand Up @@ -491,14 +519,6 @@
BE90F9041B4EDF7300CD278B /* AZSUriQueryBuilder.m */,
BE4510461A9D252300C3F971 /* Supporting Files */,
B0432F5C1CE3B05D00FF4E5A /* AZSULLRange.h */,
57E472281DF73E7000B343AB /* AZSServiceProperties.m */,
57E4722A1DF7423A00B343AB /* AZSServiceProperties.h */,
57F37C011E1F09BB00FF130F /* AZSLoggingProperties.h */,
57F37C021E1F1D3400FF130F /* AZSMetricsProperties.h */,
57F37C031E1F290A00FF130F /* AZSLoggingProperties.m */,
57F37C051E1F292800FF130F /* AZSMetricsProperties.m */,
57F37C0A1E2022B900FF130F /* AZSCorsRule.h */,
57F37C0B1E2022D300FF130F /* AZSCorsRule.m */,
);
name = AZSClient;
path = "Azure Storage Client Library";
Expand Down Expand Up @@ -529,10 +549,10 @@
B02EF9931B14F10B005F1DE2 /* AZSBlobTestBase.m */,
B04A084A1B274C7100998078 /* AZSTestHelpers.h */,
B04A084B1B274C7100998078 /* AZSTestHelpers.m */,
B05EC6E11B28E63F0048EDD4 /* AZSBlobOutputStreamTests.m */,
B06CA9E71B748083001B7303 /* AZSTestRetry.m */,
693220411C16439500B07D98 /* AZSTestSemaphore.h */,
693220421C16439500B07D98 /* AZSTestSemaphore.m */,
B05EC6E11B28E63F0048EDD4 /* AZSBlobStreamTests.m */,
B082D1441BA9E0D200A39C18 /* AZSBlobSASTests.m */,
B09BDEA91C1A4BB5004D2F94 /* AZSCloudBlobDirectoryTests.m */,
B0DD6B621C2087C5004B3A7D /* AZSCloudPageBlobTests.m */,
Expand Down Expand Up @@ -584,6 +604,7 @@
B082D1851BB0D29300A39C18 /* AZSCloudBlobContainer.h in Headers */,
B082D1861BB0D29700A39C18 /* AZSBlobRequestOptions.h in Headers */,
B082D1871BB0D29E00A39C18 /* AZSCloudBlob.h in Headers */,
69F68DAE1C653EA70056D9E3 /* AZSStreamDownloadBuffer.h in Headers */,
B082D1881BB0D2A100A39C18 /* AZSBlockListItem.h in Headers */,
B082D1891BB0D2A400A39C18 /* AZSBlobContainerProperties.h in Headers */,
B082D18A1BB0D2A600A39C18 /* AZSBlobProperties.h in Headers */,
Expand All @@ -607,6 +628,7 @@
B082D1921BB0D2D100A39C18 /* AZSResultSegment.h in Headers */,
B082D1931BB0D2D400A39C18 /* AZSContinuationToken.h in Headers */,
B082D1941BB0D2D600A39C18 /* AZSAccessCondition.h in Headers */,
69F68DB21C6550C10056D9E3 /* AZSBlobInputStream.h in Headers */,
B082D1951BB0D2D900A39C18 /* AZSRetryInfo.h in Headers */,
57746E391E97FADB007F9CB9 /* AZSMetricsProperties.h in Headers */,
57E4722B1DF7423A00B343AB /* AZSServiceProperties.h in Headers */,
Expand Down Expand Up @@ -782,6 +804,7 @@
57F37C061E1F292800FF130F /* AZSMetricsProperties.m in Sources */,
BE90F9011B3DEC7900CD278B /* AZSNavigationUtil.m in Sources */,
B01AF5F21AE053BE009A2022 /* AZSCloudBlobContainer.m in Sources */,
69F68DB01C653F3F0056D9E3 /* AZSStreamDownloadBuffer.m in Sources */,
B058A4971B55628700BB0F57 /* AZSBlobUploadHelper.m in Sources */,
B01AF5FB1AE0715D009A2022 /* AZSStorageCredentials.m in Sources */,
69A278041C24A4DB00981FF0 /* AZSSharedAccessAccountParameters.m in Sources */,
Expand All @@ -795,6 +818,7 @@
B07ED5811AE85E1B0012E8C1 /* AZSUtil.m in Sources */,
B07ED56D1AE6CE6A0012E8C1 /* AZSBlobRequestFactory.m in Sources */,
B07ED58A1AE9AEDF0012E8C1 /* AZSAccessCondition.m in Sources */,
69F68DB41C6942330056D9E3 /* AZSBlobInputStream.m in Sources */,
BE7E3E5F1B1F9AEB00BC96B6 /* AZSRequestFactory.m in Sources */,
57F37C041E1F290A00FF130F /* AZSLoggingProperties.m in Sources */,
);
Expand All @@ -814,7 +838,7 @@
B01B6C2A1C24ADEA004D7CFE /* AZSCloudAppendBlobTests.m in Sources */,
B04A084C1B274C7100998078 /* AZSTestHelpers.m in Sources */,
B05A0E7E1B1264E8005DCF06 /* AZSCloudBlobClientTests.m in Sources */,
B05EC6E21B28E63F0048EDD4 /* AZSBlobOutputStreamTests.m in Sources */,
B05EC6E21B28E63F0048EDD4 /* AZSBlobStreamTests.m in Sources */,
B06CA9E81B748083001B7303 /* AZSTestRetry.m in Sources */,
BE7E3E641B277DB100BC96B6 /* AZSNoOpAuthenticationHandler.m in Sources */,
B09BDEAA1C1A4BB5004D2F94 /* AZSCloudBlobDirectoryTests.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// -----------------------------------------------------------------------------------------
// <copyright file="AZSBlobInputStream.h" company="Microsoft">
// Copyright 2015 Microsoft Corporation
//
// Licensed under the MIT License;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://spdx.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
// -----------------------------------------------------------------------------------------

#import <Foundation/Foundation.h>
#import "AZSMacros.h"

AZS_ASSUME_NONNULL_BEGIN

@class AZSCloudBlob;
@class AZSAccessCondition;
@class AZSBlobRequestOptions;
@class AZSStreamDownloadBuffer;
@class AZSOperationContext;

/** An AZSBlobInputStream is used to read data from a blob on the service.

The AZSBlobInputStream class inherits from NSInputStream, and is designed to be used similarly.
To create an AZSBlobInputStream instance, call the createInputStream method on an instance of AZSCloudBlob.
Just like a regular Input 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.
*/
@interface AZSBlobInputStream : NSInputStream <NSStreamDelegate>

-(instancetype)initWithBlob:(AZSCloudBlob *)blob accessCondition:(AZSAccessCondition *)accessCondition requestOptions:(AZSNullable AZSBlobRequestOptions *)requestOptions operationContext:(AZSOperationContext *)operationContext AZS_DESIGNATED_INITIALIZER;

// NSStream methods and properties:
@property (readonly) NSStreamStatus streamStatus;
@property (readonly, copy, AZSNullable) NSError *streamError;
@property (assign, AZSNullable) id<NSStreamDelegate> delegate;
@property (strong, readonly) AZSStreamDownloadBuffer *downloadBuffer;

-(void)open;
-(void)close;

-(AZSNullable id)propertyForKey:(NSString *)key;
-(BOOL)setProperty:(AZSNullable id)property forKey:(NSString *)key;

-(void)scheduleInRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;
-(void)removeFromRunLoop:(NSRunLoop *)runLoop forMode:(NSString *)mode;

// NSInputStream methods and properties:
@property (readonly) BOOL hasBytesAvailable;

-(NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length;
-(BOOL)getBuffer:(uint8_t * __AZSNullable * __nonnull)buffer length:(NSUInteger *)length;

@end

AZS_ASSUME_NONNULL_END
Loading