I have stored images in a oracle table within a BLOB column. I use to read and output an image and write data using JAVA. I would like to do the same (getting my image and distributing it) with python. I am using Flask framework and cx_Oracle.
I manage to get my BLOB content into my application but I am not sure how to generate an image from that.
I know that in Java i used :
OutputStream out = response.getOutputStream(); response.setContentType(doc.getContentType()); IOUtils.copy( new ByteArrayInputStream(doc.getContent()),out); out.flush();
where doc.getContent() is my BLOB content.
Using Flask and your help :
@app.route('/_photo/') def gripur(): conn = cx_Oracle.connect("*****","****",make_dsn_tns(get_config_string())) curs = conn.cursor() #find photo document=curs.execute('select myblob from mytable where id=34234') row = cursor.fetchone() imageBlob = row blob= imageBlob.read() response = make_response(blob) response.headers["Content-type"] = "image/jpeg" conn.close() return response