0

i uploaded the image to my server using Base64 string. but its was taken more time to upload on server. i will give the code below. please help.

 NSString *locationOfWebService = @"my url";

    NSString *urlString = [NSString stringWithFormat:@"%@updateUserProfile",locationOfWebService];

    NSLog(@"image--%@",chosenImage);
    NSData* data = UIImageJPEGRepresentation(chosenImage, 1.0f);
    NSString *strEncoded = [Base64 encode:data];


    //    NSString * requestBody= [NSString stringWithFormat:@"userid=%@&tokenid=%@&password=%@&image=%@&username=%@&phone=%@&country=%@&statusmessage=%@&notificationstatus=%@&countryid=%@&apptID=%@&address=%@&city=%@&state=%@&zipcode=%@",appdel.usrId,@"",txtPass.text,strEncoded,txtName.text,@"",txtCountry.text,StatusLabale.text,@"false",@"1",txtApartNo.text,txtAddress.text,txtCity.text,txtState.text,txtZipcode.text];



    NSString * requestBody= [NSString stringWithFormat:@"userid=%@&tokenid=%@&password=%@&image=%@&username=%@&phone=%@&country=%@&statusmessage=%@&notificationstatus=%@&countryid=%@&apptID=%@&address=%@&city=%@&state=%@&zipcode=%@",appdel.usrId,token,@"",strEncoded,@"",@"",@"",@"",@"false",@"1",@"",@"",@"",@"",@""];


    NSLog(@"string----%@",requestBody);

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@"POST"];
    [request setHTTPBody: [requestBody dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLConnection *connect=[[NSURLConnection alloc]initWithRequest:request delegate:self];

    if (connect){
        webData = [[NSMutableData alloc]init];
    }
    else
    {

     }
Jashu
  • 13
  • 4

1 Answers1

0

base64 encoding makes the file larger by approximately 37% (see this post), so it's supposed to be larger and slower to upload.

Community
  • 1
  • 1