如何使用 Restkit 上传音频文件?我查看了文档,似乎找不到有关上传文件的任何信息。感谢您的帮助。
这篇文章解释了如何:http://mobile.tutsplus.com/tutorials/iphone/advanced-restkit-development_iphone-sdk/
摘录:
NSString* myFilePath = @"/some/path/to/picture.gif";
RKParams* params = [RKParams params];
// Set some simple values -- just like we would with NSDictionary
[params setValue"Blake" forParam"name"];
[params setValue"[email protected]" forParam"email"];
// Create an Attachment
RKParamsAttachment* attachment = [params setFile:myFilePath forParam"image1"];
attachment.MIMEType = @"image/gif";
attachment.fileName = @"picture.gif";
// Attach an Image from the App Bundle
UIImage* image = [UIImage imageNamed"another_image.png"];
NSData* imageData = UIImagePNGRepresentation(image);
[params setData:imageData MIMEType"image/png" forParam"image2"];
// Let's examine the RKRequestSerializable info...
NSLog(@"RKParams HTTPHeaderValueForContentType = %@", [params HTTPHeaderValueForContentType]);
NSLog(@"RKParams HTTPHeaderValueForContentLength = %d", [params HTTPHeaderValueForContentLength]);
// Send a Request!
[[RKClient sharedClient] post"/uploadImages" params:params delegate:self];
享受吧!
关于objective-c - 如何在 iOS 中使用 Reskit 上传文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12199228/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |