tags:

views:

68

answers:

1

Hi guy's

When I am uploading the video file to the server I sending the sample file name to it. I am bit confused how to upload the video file with different file names. Due to this I am getting the same video file every time.

My code is:

- (NSData *)generatePostDataForData:(NSData *)uploadData
{
// Generate the post header:
NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"uploadedfile\"; filename=\"videofile.3gp\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];
// Get the post header int ASCII format:
NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
// Generate the mutable data variable:
NSMutableData *postData = [[NSMutableData alloc] initWithLength:[postHeaderData length] ];
[postData setData:postHeaderData];

// Add the video:
[postData appendData: uploadData];

// Add the closing boundry:
[postData appendData: [@"\r\n--AaB03x--" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];

// Return the post data:
return postData;
}

Guy's please help me how to get rid of this.

Thank you, Monish.

A: 

Your line

NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"uploadedfile\"; filename=\"videofile.3gp\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];

includes the filename. Chose another there.

Eiko
I tried like this,it showing warnings
[post appendData:[[NSString stringWithFormat:"--AaB03x\r\nContent-Disposition: form-data; name=\"uploadedfile\"; filename=\"%@.3gp\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n",[NSDate date]] dataUsingEncoding:NSUTF8StringEncoding]];
Build a NSString from the date first with an NSDateFormatter-
Eiko
Thanks for your valuable suggestions its working fine.