Skip to content

Commit

Permalink
添加上传图片的接口
Browse files Browse the repository at this point in the history
  • Loading branch information
锦超 committed Sep 5, 2015
1 parent 8d57c1b commit 9995955
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 27 deletions.
12 changes: 0 additions & 12 deletions YHB_Prj/YHB_Prj/FirstViewController/FirstVCManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,4 @@ - (void)getHomePageInfoApp:(NSString *)aStoreId
}];
}

- (void)uploadImg
{
NSString *resourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"[email protected]"];
//JFB_First_Close@2x
[NetManager uploadImg:[UIImage imageNamed:@"clerk_1"] imgFilePath:resourcePath parameters:nil apiName:@"uploadUserFacePic" uploadUrl:nil uploadimgName:@"image" progressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {

} succ:^(NSDictionary *successDict) {

} failure:^(NSDictionary *failDict, NSError *error) {

}];
}
@end
1 change: 0 additions & 1 deletion YHB_Prj/YHB_Prj/FirstViewController/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ - (void)requestHomeData
#pragma mark Head 部分 日期按钮的事件及页面操作回调
- (void)head_rbtItem:(UIButton *)abt
{
// [self.manager uploadImg];
self.dateVC = (DateSelectVC *)[self pushXIBName:@"DateSelectVC" animated:YES selector:nil param:nil];
[self obserDateVCValue];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
[[SDImageCache sharedImageCache] storeImage:image
forKey:userFace
toDisk:YES];
[NetManager uploadImg:image imgFilePath:nil parameters:nil apiName:@"uploadUserFacePic" uploadUrl:nil uploadimgName:nil progressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
[NetManager uploadImg:image parameters:nil apiName:@"uploadUserFacePic" uploadUrl:nil uploadimgName:nil progressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
MLOG(@"%f", (float)totalBytesExpectedToWrite/totalBytesWritten);
} succ:^(NSDictionary *successDict) {
MLOG(@"1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
failure:(FAILUREBLOCK)failure;

+ (void)uploadImg:(UIImage*)aImg
imgFilePath:(NSString *)aFilePath
parameters:(NSDictionary*)aParam
apiName:(NSString *)aApidName
uploadUrl:(NSString*)aUrl
Expand Down
14 changes: 2 additions & 12 deletions YHB_Prj/YHB_Prj/ThirdParty/AFNetworking/NetManager/NetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ + (void)cancelOperation:(id)aKey
}

+ (void)uploadImg:(UIImage*)aImg
imgFilePath:(NSString *)aFilePath
parameters:(NSDictionary*)aParam
apiName:(NSString *)aApidName
uploadUrl:(NSString*)aUrl
Expand All @@ -279,24 +278,15 @@ + (void)uploadImg:(UIImage*)aImg
param = [[NetManager shareInstance] basePostDict:aParam apiName:aApidName];
dict = [NSMutableDictionary dictionaryWithDictionary:aParam];
[dict setValue:param forKey:@"S3CAPI"];

[manager.requestSerializer setValue:param forHTTPHeaderField:@"S3CAPI"];
[NetManager setRequestHeadValue:manager];
if([kBaseUrl compare:@"https://api.chinascrm.com/sapi4app.html"] == 0)
{
manager.securityPolicy.allowInvalidCertificates = YES;
}

[manager POST:kBaseUrl parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
//[formData appendPartWithFileURL:[NSURL URLWithString:aFilePath] name:@"pic" error:nil];
[formData appendPartWithFileData:imageData name:@"imgage" fileName:@"img.jpg" mimeType:@"image/jpeg"];
// if(aImgname)
// {
// [formData appendPartWithFormData:imageData name:aImgname];
// }
// else
// {
// [formData appendPartWithFormData:imageData name:@"image"];
// }
[formData appendPartWithFileData:imageData name:@"pic" fileName:@"temp_image.jpg" mimeType:@"application/octet-stream"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *Dict = [operation.responseString objectFromJSONString];
success(Dict);
Expand Down

0 comments on commit 9995955

Please sign in to comment.