Created
June 19, 2014 03:52
-
-
Save fishkingsin/7b2075413e6bd736e642 to your computer and use it in GitHub Desktop.
the removed routin about save json and send zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
NSString *url = [NSString stringWithFormat:@"%@%@%@",kAPIScheme, kBaseURL, USER_TRACKING_DATA]; | |
[manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { | |
ZipArchive *zip1 = [[ZipArchive alloc] init]; | |
BOOL ret = [zip1 CreateZipFile2:[documentsDirectory stringByAppendingPathComponent:@"data.zip"]]; | |
//convert plist to JSON | |
NSError *error = nil; | |
NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:jsonPath append:NO]; | |
[outputStream open]; | |
NSMutableArray *savedStock = [[NSMutableArray alloc] initWithContentsOfFile: path]; | |
// NSString *jsonString = [savedStock JSONString]; | |
[NSJSONSerialization writeJSONObject:savedStock | |
toStream:outputStream | |
options:0 | |
error:&error]; | |
[outputStream close]; | |
ret = [zip1 addFileToZip:jsonPath newname:@"data.json"]; | |
[zip1 CloseZipFile2]; | |
[formData appendPartWithFileData:[NSData dataWithContentsOfFile:[documentsDirectory stringByAppendingPathComponent:@"data.zip"]] name:@"FILE" fileName:@"data.zip" mimeType:@"application/zip"]; | |
} success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
DDLogPace(@"%@",responseObject); | |
NSString *zipPath = [documentsDirectory stringByAppendingPathComponent:@"data.zip"]; //3 | |
if ([fileManager fileExistsAtPath: zipPath]) //4 | |
{ | |
[fileManager removeItemAtPath:zipPath error:NULL]; | |
} | |
if ([fileManager fileExistsAtPath: path]) //4 | |
{ | |
[fileManager removeItemAtPath:path error:NULL]; | |
} | |
if ([fileManager fileExistsAtPath: jsonPath]) //4 | |
{ | |
[fileManager removeItemAtPath:path error:NULL]; | |
} | |
//if send success block the routine here | |
//other othewise accuminate the list | |
return; | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
DDLogPace(@"%@",error); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment