What is the most efficient binary to text encoding?

This really depends on the nature of the binary data, and the constraints that “text” places on your output. First off, if your binary data is not compressed, try compressing before encoding. We can then assume that the distribution of 1/0 or individual bytes is more or less random. Now: why do you need text? … Read more

Use binary COPY table FROM with psycopg2

Here is the binary equivalent of COPY FROM for Python 3: from io import BytesIO from struct import pack import psycopg2 # Two rows of data; “id” is not in the upstream data source # Columns: node, ts, val1, val2 data = [(23253, 342, -15.336734, 2494627.949375), (23256, 348, 43.23524, 2494827.949375)] conn = psycopg2.connect(“dbname=mydb user=postgres”) curs … Read more

How to insert images in mongoDB using java?

For storing binary data like images you can use GridFS or implement your own realization; Download the driver and look at src/test/com/mongodb/gridfs/GridFSTest.java 😉 Edit: you are lucky today! I made complete code for you;) Enjoy! package mongodb.testing.java; import com.mongodb.*; import com.mongodb.gridfs.*; import java.io.*; public class Main { public static byte[] LoadImage(String filePath) throws Exception { … Read more

Sending binary data over http

Will simply sending base64 encoded data work? There is no need to use base 64 encoding – this will simply increase the number of bytes you must transfer. Mobile operators normally limit mangling of responses to content types that they understand – i.e. images, stylesheets, etc. How are the HTTP sessions handled? HTTP sessions are … Read more

Would you store binary data in database or in file system? [closed]

The advantage of storing data in the DB is taking advantage of DB security mechanisms and reducing maintanence cost (backups, …). The disadvantage of it is increasing DB load and consuming connections (which might be expensive for per-connection licensed database servers). If you are using SQL Server 2008, FILESTREAM might be a nice alternative. By … Read more

How to build PDF file from binary string returned from a web-service using javascript

Is there any solution like building a pdf file on file system in order to let the user download it? Try setting responseType of XMLHttpRequest to blob , substituting download attribute at a element for window.open to allow download of response from XMLHttpRequest as .pdf file var request = new XMLHttpRequest(); request.open(“GET”, “/path/to/pdf”, true); request.responseType … Read more