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];
}