gavinkwoe / BeeFramework

[Experimental] A semi-hybrid framework that allows you to create mobile apps using Objective-C and XML/CSS
MIT License
3.33k stars 1.06k forks source link

新增json对post文件的支持,使用方法: #120

Closed cdoky closed 9 years ago

cdoky commented 9 years ago

"POST /BBS/TestUpload": { "request": { "uEmail":"" }, "fileList": { "pic1":"{jpg}", "pic2":"{png}", "pic3":"{file}" } }

生成的post请求代码如下: if ( self.sending ) { if ( nil == self.req || NO == [self.req validate] ) { self.failed = YES; return; }

    NSString * requestURI = [[ServerConfig sharedInstance].url stringByAppendingString:@"/BBS/TestUpload"];
    self.HTTP_POST( requestURI ).PARAM(@"json", [self.req objectToDictionary] ).FILE_JPG(@"pic1", self.fileList.pic1).FILE(@"pic3", self.fileList.pic3).FILE_PNG(@"pic2", self.fileList.pic2);
}

使用方法如下: API_BBS_TESTUPLOAD *api = [API_BBS_TESTUPLOAD apiWithResponder:self]; api.fileList.pic3 = [[NSData alloc] init]; api.fileList.pic2 = [[UIImage alloc] init]; api.fileList.pic1 = [[UIImage alloc] init]; [api send];