简体   繁体   中英

upload video from Iphone application on .NET server using webservice

I have writen client code in Iphone.

self.postRequest = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://Services/UploadVideo.asmx"]];

NSString *urlString=[self.videoURL path];
NSLog(@"urlString=%@",urlString);
[self.postRequest setFile:urlString forKey:@"videoUrl"];
[self.postRequest setRequestMethod:@"POST"];
[self.postRequest setDelegate:self];
[self.postRequest setDidFailSelector:@selector(postFailed:)];
[self.postRequest setDidFinishSelector:@selector(postSuccessful:)];
[self.postRequest startAsynchronous];

LOG output:// urlString=/private/var/mobile/Applications/09108E9E-1494-4C25-8C3E-328B95BD1504/tmp/capture-T0x1e569fd0.tmp.w37766/capturedvideo.MOV

How should I capture it and save it on the server? Thanks in advance..

First of all you need to convert the video into nsdata

NSData *data = [NSData dataWithContentsOfFile:video_url];

and then convert the nsdata to base64 string (you need to download the seperate file for base64)

NSString *encodedString=[data base64EncodedString];

so finally you can send the encoded string to your .net server (you need to decode the encoded string in your .net server to retrieve the video)

Above code is worked for me as image conversion (i think it will work for the video also)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM