简体   繁体   English

如何将图像作为多部分表单对象作为参数从url发送到iOS到Spring MVC

[英]How to send an image as multipart form object as a parameter to url from ios to spring mvc

How to send an image as Multipart form object as a parameter to url from ios to spring mvc 如何将图像作为Multipart表单对象作为参数发送到ios从url到Spring MVC

url which is accepting at the back end in www.test.com?id=test&multipartforObject= 在www.test.com?id=test&multipartforObject=后端接受的网址

So in IOS how can i convert the image to Multipartform object to pass it as param along with the URL. 因此,在IOS中,如何将图像转换为Multipartform对象,以将其作为参数与URL一起传递。

Manjush 文殊

In practice, many clients and servers do only support URLs up to a certain length.If you pass image as param along with the URL,sometimes, URL's length maybe to too long. 实际上,许多客户端和服务器仅支持最大长度的URL。如果将图像作为参数与URL一起传递,有时URL的长度可能会太长。

I suggest using HTTP/POST to upload multipart files.There is some sample code using ASIFormDataRequest to upload multipart files: 我建议使用HTTP / POST上传多部分文件。有一些示例代码使用ASIFormDataRequest上传多部分文件:

NSData * imageData1 = UIImageJPEGRepresentation([UIImage imageNamed:@"image1.png"] ,0.6);
NSData * imageData2 = UIImageJPEGRepresentation([UIImage imageNamed:@"image3.png"] ,0.6);
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addData:imageData1 withFileName:@"image1.jpg" andContentType:@"image/jpg" forKey:@"certImage"];
[request addData:imageData2 withFileName:@"image2.jpg" andContentType:@"image/jpg" forKey:@"certImage"];
[request startAsynchronous];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在iOS,Swift3,Alamofire 4中使用多部分表单数据将图像作为参数上传以及其他参数 - How to upload image as a parameter, with other parameters using multipart form data in ios, swift3, Alamofire 4 使用Multipart上传图像并将多部分对象作为参数发布到Spring MVC控制器 - Uploading an image using Multipart and posting multipart object as a param to spring mvc controller 我应该如何在 iOS 中通过 multipart/form-data 发送字典? - How should I send a dictionary by multipart/form-data in iOS? 如何在iOS Objective C中发送包含多部分表单数据的放置请求? - How to send put request with multipart form data in iOS objective c? 如何在iOS中将对象作为POST请求的参数发送? - How to send an object as a parameter for a POST request in iOS? 在iOS中将图像(png / jpeg)转换为多部分对象 - Convert an image (png/jpeg) to multipart object in iOS 如何在iOS中使用参数从浏览器打开URL - How to open an url from the browser with a parameter in ios 使用 AlmoFire 在 iOS Swift 中多部分形式 PUT 请求中的 JSON 参数 - JSON parameter in multipart form PUT request in iOS Swift using AlmoFire swift中如何上传带有参数multipart的图片 - How to upload image with parameter multipart in swift 在ios中分段上传表格,如何完成? - Multipart form upload in ios, How is it done?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM