开发者

How do you save a file from S3 using the AWS iOS SDK? [closed]

Closed. This question does not meet Stack Overf开发者_Go百科low guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 4 days ago.

Improve this question

I'm looking for a super simple example of how to do a getObject from S3 using their iOS SDK: http://aws.amazon.com/sdkforios/

Specifically the part on how to write the response results to a file.


The problem seems to be that although S3GetObjectReponse has setOutputStream, the only way to get S3GetObjectResponse is via [[AmazonClientManager s3] getObject:getObjectRequest]; And it might be too late by then.

So, set the output stream in the request:

S3GetObjectRequest  *getObjectRequest  = [[[S3GetObjectRequest alloc]  ....];
getObjectRequest.outputStream = ...;

See S3GetObjectRequest:

- (NSOutputStream *) outputStream 

[read, write, assign]

Gets and Sets the output stream for the response data.

If this is set, then the response will write the data to the supplied stream instead of making it available through the data property.

The stream must be opened and scheduled in the desired runloop. The SDK will not close the stream.


I took a look at the API documentation for S3GetObjectResponse.h:

00020 @interface S3GetObjectResponse : S3Response {
00021         NSString *contentType;
00022         NSMutableDictionary *metadata;
00023         NSOutputStream *outputStream;
00024 }
00025 
00027 @property(nonatomic, retain) NSString* contentType;
00028 
00033 -(NSString *)getMetadataForKey:(NSString *)aKey;
00034 
00041 -(void)setOutputStream:(NSOutputStream *)stream;

Perhaps you can set the S3 response's NSOutputStream using its -setOutputStream: method. You could then perhaps write that stream to a file using one of the NSOutputStream instance methods. For iOS apps, you can write data to a file in one of three specific folders.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜