0
上传我的图像在亚马逊s3 bucket.im在一个单独的类中编写我的代码Amazons3, 我得到一个错误实例变量s3在类method.how中访问来解决此错误.im为变量初始化创建一个构造函数。您可以帮我解决问题。在类方法中访问的实例变量s3
-(id) init
{
self = [super init];
if(self)
{
if(self.s3 == nil)
{
// Initial the S3 Client.
self.s3 = [[AmazonS3Client alloc] initWithAccessKey:ACCESS_KEY_ID withSecretKey:SECRET_KEY];
}
}
return self;
}
+(void)uploadImage:(Products *)product
{
NSData *uploadData = [NSData dataWithContentsOfFile:[Util getFilePathForFileName:[NSString stringWithFormat:@"%@ios.mp4",product.productImageUrl]]];
S3PutObjectRequest *por = [[S3PutObjectRequest alloc] initWithKey:[NSString stringWithFormat:@"%@.mp4",product.productImageUrl] inBucket:BUCKET_NAME];
por.contentType = @"application/octet-stream";
por.cannedACL = [S3CannedACL publicRead];
por.data = uploadData;
S3PutObjectResponse *putObjectResponse = [s3 putObject:por];
if(putObjectResponse.error !=nil)
[self performSelectorOnMainThread:@selector(showCheckErrorMessage:) withObject:putObjectResponse.error waitUntilDone:NO];
}