I have an NSInputStream that I'm sending to server and while upload is going on, I want to display image that's uploading. Method is located in singleton and it's receiving that NSInputStream. Is there a way to read that stream and convert it to UIImage?
I've tried with this, but no luck. Where is my mistake?
var buffer = [UInt8](count:1024, repeatedValue: 0)
thumbnailStream.open()
if (thumbnailStream.hasBytesAvailable){
let len : Int = inputStream.read(&buffer, maxLength: buffer.count)
var pictureData = NSData(bytes: buffer, length: len)
var imagess = UIImage(data: pictureData)!
self.headerProgress.imageView.image = imagess
print("Data of image = \(pictureData.length)")
}else{
print("No bytes")
}
Thanks!