convert outputstream to inputstream