With the AWSiOS SDK how do you do a HEAD request on an S3 object?

别说谁变了你拦得住时间么 提交于 2019-12-06 06:22:37

I am a maintainer of the AWS SDK for iOS. You can also use the S3GetObjectMetadataRequest to do the same thing.

S3GetObjectMetadataRequest *request = 
[[S3GetObjectMetadataRequest alloc] initWithKey:FILE_NAME withBucket:BUCKET_NAME];
S3GetObjectMetadataResponse *response = [s3 getObjectMetadata:request];
int64_t fileSize = response.contentLength;

Turned out to be fairly straight forward, but still wondering if there's a more accepted way of doing a HEAD.

S3GetObjectRequest *headRequest = [[[S3GetObjectRequest alloc] initWithKey:keyname withBucket: [bucketname]] autorelease];
headRequest.httpMethod = @"HEAD";

S3Response *headResponse = [[S3Response alloc] init];
headResponse = [self.awsConnection invoke:headRequest];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!