In the method:
private func body(from request: URLRequest) -> Data? { return request.httpBody ?? request.httpBodyStream.flatMap { stream in let data = NSMutableData() stream.open() while stream.hasBytesAvailable { var buffer = [UInt8](repeating: 0, count: 1024) let length = stream.read(&buffer, maxLength: buffer.count) data.append(buffer, length: length) } stream.close() return data as Data } }
In the row "data.append(buffer, length: length)"
I'm getting a crash, when my app is uploading a chunk of data:
Terminating app due to uncaught exception 'NSRangeException', reason: ' -[NSConcreteMutableData appendBytes:length:]: range {204800, 18446744073709551615} causes integer overflow'
The file is not so big - a photo sent as a single chunk.
In the method:
private func body(from request: URLRequest) -> Data? { return request.httpBody ?? request.httpBodyStream.flatMap { stream in let data = NSMutableData() stream.open() while stream.hasBytesAvailable { var buffer = [UInt8](repeating: 0, count: 1024) let length = stream.read(&buffer, maxLength: buffer.count) data.append(buffer, length: length) } stream.close() return data as Data } }
In the row "data.append(buffer, length: length)"I'm getting a crash, when my app is uploading a chunk of data:
Terminating app due to uncaught exception 'NSRangeException', reason: ' -[NSConcreteMutableData appendBytes:length:]: range {204800, 18446744073709551615} causes integer overflow'
The file is not so big - a photo sent as a single chunk.