ios - Update AWSS3 with Cocoapods -
in project have 2 frameworks: awsruntime & awss3 , use upload images.
- (void)updateawscredentials:(nsdictionary *)awsobject { if(awsobject && [awsobject iskindofclass:[nsdictionary class]]) { self.key = awsobject[@"accesskeyid"]; self.secret = awsobject[@"secretaccesskey"]; self.token = awsobject[@"sessiontoken"]; self.profileimagepath = awsobject[@"fileprefixprofile"]; self.postimagepath = awsobject[@"fileprefixpost"]; self.bucket = awsobject[@"bucketname"]; } } - (nsstring *)uploadimageobject:(haamazonimagecontainer *)imageobject { nsdata *imagedata = uiimagejpegrepresentation(imageobject.image, 1.0); nsstring *imagekey = [nsstring stringwithformat:@"%@_%f", imageobject.userid, [[nsdate date] timeintervalsince1970]]; imagekey = [imagekey stringbyreplacingoccurrencesofstring:@"." withstring:@"0"]; nsstring *imagepath = self.postimagepath; if(imageobject.imagepath != haamazonpostimagepath) { imagepath = self.profileimagepath; } @try{ // create s3 client. amazoncredentials *lcredentials = [[amazoncredentials alloc] initwithaccesskey:self.key withsecretkey:self.secret withsecuritytoken:self.token]; amazons3client *s3 = [[amazons3client alloc] initwithcredentials:lcredentials]; s3putobjectrequest *por = [[s3putobjectrequest alloc] initwithkey:[nsstring stringwithformat:@"%@/%@.jpeg", imagepath, imagekey] inbucket:self.bucket]; por.contenttype = @"image/jpeg"; por.cannedacl = [s3cannedacl publicread]; por.data = imagedata; por.delegate = self; s3.endpoint = [amazonendpoints s3endpoint:us_west_2]; [s3 putobject:por]; } @catch (amazonclientexception *exception) { nslog(@"exception"); } return [nsstring stringwithformat:@"http://%@/%@", self.bucket, [nsstring stringwithformat:@"%@/%@.jpeg", imagepath, imagekey]]; } -(void)request:(amazonservicerequest *)request didcompletewithresponse:(amazonserviceresponse *)response { nslog(@"complete response"); if([request iskindofclass:[s3putobjectrequest class]]) { s3putobjectrequest *requestobj = (s3putobjectrequest *)request; nsstring *key = @""; nsarray *keys = [requestobj.key componentsseparatedbystring:@"/"]; if(keys.count == 2) { key = keys[1]; } nsdictionary *userinfo = [[nsdictionary alloc] initwithobjectsandkeys:key, image_key, nil]; [[nsnotificationcenter defaultcenter] postnotificationname:khaamazondiduploadimage object:nil userinfo:userinfo]; } }
now want move cocoapods. i've imported awss3 pod 'awss3'
, error: "cannot find protocol declaration 'amazonservicerequestdelegate'". find amazonservicerequestdelegate declaration or deprecated? clear question?
you using version 1 of aws mobile sdk ios. officially started supporting cocoapods version 2 of sdk, , awss3
used pull down version 2 of sdk. cannot use cocoapods install aws mobile sdk until migrate app use aws mobile sdk ios v2.
aws mobile sdk ios developer guide may started version 2 of sdk. please note not have backward compatibility version 1 of sdk.
Comments
Post a Comment