gpt4 book ai didi

objective-c - 如何在 iOS 中使用 Reskit 上传文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:49:01 24 4
gpt4 key购买 nike

我将如何使用 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:@"blake@restkit.org" 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com