我在亚马逊 s3 存储桶中上传我的图像。我在一个单独的类 Amazons3 中编写我的代码,我得到一个在类方法中访问的错误实例变量 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];
}