objective-c - 如何在 iOS 中使用 Reskit 上传文件
<p><p>如何使用 Restkit 上传音频文件?我查看了文档,似乎找不到有关上传文件的任何信息。感谢您的帮助。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这篇文章解释了如何:<a href="http://mobile.tutsplus.com/tutorials/iphone/advanced-restkit-development_iphone-sdk/" rel="noreferrer noopener nofollow">http://mobile.tutsplus.com/tutorials/iphone/advanced-restkit-development_iphone-sdk/</a> </p>
<p>摘录:</p>
<pre><code>NSString* myFilePath = @"/some/path/to/picture.gif";
RKParams* params = ;
// Set some simple values -- just like we would with NSDictionary
;
;
// Create an Attachment
RKParamsAttachment* attachment = ;
attachment.MIMEType = @"image/gif";
attachment.fileName = @"picture.gif";
// Attach an Image from the App Bundle
UIImage* image = ;
NSData* imageData = UIImagePNGRepresentation(image);
;
// Let's examine the RKRequestSerializable info...
NSLog(@"RKParams HTTPHeaderValueForContentType = %@", );
NSLog(@"RKParams HTTPHeaderValueForContentLength = %d", );
// Send a Request!
[ post:@"/uploadImages" params:params delegate:self];
</code></pre>
<p>享受吧!</p></p>
<p style="font-size: 20px;">关于objective-c - 如何在 iOS 中使用 Reskit 上传文件,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/12199228/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/12199228/
</a>
</p>
页:
[1]