Uploading .db file to server..disk image malformed?

283 Views Asked by At

Can some please help in understanding what is going wrong???

I will have upload my .db file to server using multipart/formdata request. I'm using ASIFormdataRequest to form the request and i'm getting the response as success.But when I try to download the file I'm getting disk image malformed. I'm pasting the code

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSString* path = [self FilePath];
NSData *dataBaseData = [NSData alloc];
dataBaseData = [NSData dataWithContentsOfFile:path];
NSLog(@"databaselength %d",dataBaseData.length);
NSString* authHeader = [self returnAuthHeader];
NSLog(@"Auth Header %@", authHeader);
[request addRequestHeader:@"Accept" value:@"application/xml"];
[request addRequestHeader:@"Authorization" value:authHeader];
[request addRequestHeader:@"Content-Type" value:@"multipart/form-data"];

// [request setFile:dataBaseData withFileName:@"sample.db" andContentType:@"multipart/form-data" forKey:@"filedata"];
[request addData:dataBaseData withFileName:@"sample.db" andContentType:@"application/octet-stream" forKey:@"filedata"];

[request setPostFormat:ASIMultipartFormDataPostFormat];
[request setDelegate:self];
NSLog(@"Request %@",request);
[request updateUploadProgress];
[request startAsynchronous];
1

There are 1 best solutions below

0
On

Found why db got corrupted and gave Disk image malformed!!!!!!

Was reading the db in a file in one thread and inserting values to the tables in the db in another thread.So the integrity of the db was not maintained.