将图像从 iPhone 上传到 WCF 服务

2023-12-06

我正在尝试构建一个 iPhone 应用程序和 c# WCF 服务来将图像上传到 SQL 服务数据库。

我的应用程序将图像分解为 NSData 并使用以下代码发布到 WCF 服务:

NSData *imageData = UIImageJPEGRepresentation(self.image, 90);

NSURL *url = [NSURL URLWithString:@"http://example.com/ImageDiaryService.svc/json/AddMediaItem"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Test" forKey:@"Name"];
[request setPostValue:@"Test description." forKey:@"Description"];
[request setPostValue:@"JPEG" forKey:@"ImageType"];
[request setPostValue:@"iPhone" forKey:@"MediaType"];

[request setData:imageData withFileName:@"myphoto.jpg" andContentType:@"image/jpeg" forKey:@"ImageData"];

[request setDidFinishSelector:@selector(uploadFinished:)];
[request setDidFailSelector:@selector(uploadFailed:)];
[request setDelegate:self];
[request startAsynchronous];

我遇到的问题是网络服务。我不确定应该从应用程序 POST 接收什么类型的数据。我尝试将其作为字节数组接收,但这不起作用。

我的 WCF 服务是 REST 服务。

任何帮助深表感谢。


尝试将其作为流接收。博客文章位于http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-任意-data.aspx演示如何在 WCF REST 服务中接收任意数据。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

将图像从 iPhone 上传到 WCF 服务 的相关文章

随机推荐