用iPhone API拍照并将其传输到服务器 [英] Take picture with iPhone API and transfer it to a server
问题描述
我写了一个可可应用程序在iPhone上拍照。我需要将拍摄的图像转移到除iPhone以外的某个地方,即另一个服务器。
I have written an cocoa application to take a picture on the iPhone. I need to transfer the images taken to somewhere besides the iPhone namely another server. Does anyone know how I can accomplish this?
谢谢,
Joe
Thanks, Joe
推荐答案
首先得到一个服务器,找出你想使用什么样的手机< --->服务器API。有很多方法可以工作。一个简单而常见的方案是一个REST API,通过HTTP POST上传照片。
First get a server and figure out what kind of phone <---> server API you want to use. There are any number of ways it can work. A simple and common scheme is a REST API with photos being uploaded via HTTP POST.
基本方案如下:
- 拍摄照片
- 转换为JPG(有此功能)
- NSURL *类
- 将JPG数据设置为POST正文(或mutipart表单帖子的一部分)
- Take picture
- Convert to JPG (there's a function for this)
- Construct HTTP POST using the NSURL* classes
- Set JPG data as POST body (or one part of a mutipart form post)
不需要转换为base64。
Converting to base64 should not be necessary.
如果您从未将任何类型的服务器API放在一起,则有任何数量的示例可用。大多数照片共享网站都有公共API,可能是有用的参考。
If you've never put together any kind of server API, there are any number of examples available. Most photo-sharing sites have public APIs which may be useful references.
这篇关于用iPhone API拍照并将其传输到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!