i m uploading images in amazon s3 bucket.i m writing code in seperate class amazons3, m getting error instance variable s3 accessed in class method.how solve error .i m creating constructor variable initialization.could guys me out.
-(id) init { self = [super init]; if(self) { if(self.s3 == nil) { // initial 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]; }
your uploadimage:
must instance method. change signature -(void)uploadimage:(products *)product
.
your error quite self-explaining : instance attribute (per-object) cannot accessed in class method (per-class). need instanced object access object attribute ;)
Comments
Post a Comment