Request entity too large in node which use body parser is a common question and I have see a lot solutions.
The question is, when I am trying to add :
app.use(bodyParser.raw({limit: "50mb"}));// !!!!TypeError: bodyParser.raw is not a function
These code is ok but still I can not upload picture by iOS Afnetworking:
app.use(bodyParser.json({limit: "50mb"}));
app.use(bodyParser.urlencoded({limit: "50mb", extended: true, parameterLimit:50000}));
My bodyParser verision is update to 1.15.1. I use Objective C ,Afnetworking to upload:
NSString *urlString = [baseUrlString stringByAppendingString:@"account/avatar"];
NSDictionary *parameters = @{@"token": self.token};
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *url = [NSURL URLWithString:@"account/avatar" relativeToURL:self.baseUrl];
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:urlString parameters:parameters error:nil];
//[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
//[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"Success: %@ %@", response, responseObject);
}
}];
[uploadTask resume];