如何使用iphone sdk通过webservice发送附件?

时间:2021-02-24 18:11:17

In My application i have to send a file(audio,image,text and vedio etc..) to server using webservice. Here i am sending bytes to application using base64binary string. But here data is corrupted. Is there any way to sending base64binary to service.

在我的应用程序中,我必须使用webservice将文件(音频,图像,文本和视频等...)发送到服务器。这里我使用base64binary字符串向应用程序发送字节。但是这里的数据已损坏。有没有办法将base64binary发送到服务。

Or is there any way to send attachments to service or copy the file into server.

或者有没有办法发送附件服务或将文件复制到服务器。

Please any one can help me.

请任何人都可以帮助我。

Thanks in advance.

提前致谢。

-(NSMutableURLRequest *) SaveAttachments:(NSData *)data name:(NSString *)name fileType:(NSString *)type {

- (NSMutableURLRequest *)SaveAttachments:(NSData *)数据名:(NSString *)name fileType:(NSString *)type {

[self setUserCredentials];

NSString *strsdf = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *sdf=@"lll.jpg";
NSString *strt = [Base64 encode:data];
//NSLog(@"strt %@",strt);

NSString *soapMsg = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\
                     <soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\
                     <soap12:Body>\
                     <InsertAttachmentint xmlns=\"http://tempuri.org/\">\
                     <Filename>%@</Filename>\
                     <FileType>%@</FileType>\
                     <FileContentint>%@</FileContentint>\
                     </InsertAttachmentint>\
                     </soap12:Body>\
                     </soap12:Envelope>",sdf,type,strsdf];

This is the code. Here strsdf is binary

这是代码。这里strsdf是二进制的

1 个解决方案

#1


0  

I would take a loot at http://allseeing-i.com/ASIHTTPRequest/

我会在http://allseeing-i.com/ASIHTTPRequest/上拍一张战利品

This wrapper makes it MUCH easier to send and receive data with iOS.

这个包装器使得使用iOS发送和接收数据变得更加容易。

#1


0  

I would take a loot at http://allseeing-i.com/ASIHTTPRequest/

我会在http://allseeing-i.com/ASIHTTPRequest/上拍一张战利品

This wrapper makes it MUCH easier to send and receive data with iOS.

这个包装器使得使用iOS发送和接收数据变得更加容易。