binary-data

Sending binary data with HttpURLConnection

♀尐吖头ヾ 提交于 2019-12-06 13:22:00
i want to use google speech api, i've found this https://github.com/gillesdemey/google-speech-v2/ where everything is explained well, but and im trying to rewrite it into java. File filetosend = new File(path); byte[] bytearray = Files.readAllBytes(filetosend); URL url = new URL("https://www.google.com/speech-api/v2/recognize?output="+outputtype+"&lang="+lang+"&key="+key); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); //method conn.setRequestMethod("POST"); //header conn.setRequestProperty("Content-Type", "audio/x-flac; rate=44100"); now im lost... i guess i need to add

Help Reading Binary Image Data from SQL Server into PHP

女生的网名这么多〃 提交于 2019-12-06 09:25:19
I cannot seem to figure out a way to read binary data from SQL server into PHP. I am working on a project where I need to be able to store the image directly in the SQL table, not on the file system. Currently, I have been using a query like this one: INSERT INTO myTable(Document) SELECT * FROM OPENROWSET(BULK N'C:\image.jpg', SINGLE_BLOB) as BLAH This works fine to actually insert the image into the table, but I haven't yet figured a way to retrieve it and get my image back. I am doing this with PHP, and ultimately will have to make a stored procedure out of it, but can anyone enlighten me on

How send data (TCP) in binary frame format

随声附和 提交于 2019-12-06 05:12:46
I need to stream data to a TCP-server and havnt done it before. The data should be in binary frame format. I googled and found this tutorial which I think describes what I need to do: http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient(v=vs.71).aspx But I dont know how to create the data in the format needed so I can send it in the correct way. It should be in this format: Field|Offset| Type | size(octets) id | 0 |unsign int| 1 name | 1 |Byte Array| 40 grade| 41 |sign float| 8 Example: Field| Data | InBytes | id | 133 | 133 | name | 247 | 247 0 | grade| 0 | 0 | Whats the data

Convert an image to binary data (0s and 1s) in java

拟墨画扇 提交于 2019-12-06 04:14:42
问题 I want to read an image from a url and convert it into binary data. Please help me.. byte[] data = null; ByteArrayOutputStream bas = null; try { URL u = new URL( "http://www.eso.org/public/archives/images/screen/eso0844a.jpg"); HttpURLConnection con1 = (HttpURLConnection) u.openConnection(); con1.setAllowUserInteraction(true); con1.setRequestMethod("GET"); con1.connect(); InputStream is = con1.getInputStream(); BufferedImage imgToServe = null; if (is != null) { imgToServe = ImageIO.read(is);

Why are binary files corrupted when zipping them?

你。 提交于 2019-12-05 21:58:12
I have a service that delivers zipped files over the web. The zip contains executable files for the Windows platform. I'm using the RubyZip library to compress the file but the process corrupts the binary. At my local server we're using the zip command via a system call and it works fine. The zip command is not available at Heroku, and I'm simply out of options. I'm using this class: require 'zip/zip' # This is a simple example which uses rubyzip to # recursively generate a zip file from the contents of # a specified directory. The directory itself is not # included in the archive, rather just

C/C++: is it possible to pass binary data through the console? [duplicate]

*爱你&永不变心* 提交于 2019-12-05 21:25:06
This question already has answers here : What is the simplest way to write to stdout in binary mode? (2 answers) Closed 4 years ago . I would like to know if it is possible that an utility yields binary data (i.e. graphical images) and outputs them through IO console, while another application, instructed about the nature of those data and informed of the number of the incoming bytes, is able to read it from IO console. Yes, it is possible. While it's true that often stdin / stdout are meant to be text there are many programs that are designed to get binary input or write binary output from

determine if blob is an image without loading entire field?

给你一囗甜甜゛ 提交于 2019-12-05 20:32:22
is there a way to read only a few bytes out of a BLOB type field in a database (for this question it doesn't matter the DB brand) and determine if the binary content is an image (assume it is one of: JPG, GIF, PNG)? I have a webapp that stores files in the database, and if it is an image, I want to show a thumbnail, otherwise I want to show an icon... but I don't have any MIMETYPE info stored anywhere else for the blob (it's not my design)... and because it is a webapp, the loading of the image needs to occur in a separate call (getImage.ashx) from writing out the <img> tag.. and when I'm

Identifying the type of a file without extension from binary data

感情迁移 提交于 2019-12-05 19:16:04
I have some files without extension. I would like associate extensions to them. For that I have written a python program to read the data in the file. My doubt is how can I identify its type without the extension without using third party tools. I have to identify a pdf, doc and text file only. Other type of files are not possible. My server is cent os You could read the first few bytes of the file and look for a "magic number". The Wikipedia page on magic numbers suggests that PDF files begin with ASCII %PDF and doc files begin with hex D0 CF 11 E0. Identifying text files is going be pretty

StreamReader and binary data

被刻印的时光 ゝ 提交于 2019-12-05 08:06:54
I have this text file what contains different fields. Some fields may contain binary data. I need to get all the data in the file but right now when using StreamReader then it wont read the binary data block and data what comes after that. What would be the best solution to solve this problem? Example: field1|field2|some binary data here|field3 Right now i read in the file like this: public static string _fileToBuffer(string Filename) { if (!File.Exists(Filename)) throw new ArgumentNullException(Filename, "Template file does not exist"); StreamReader reader = new StreamReader(Filename,

Inserters and Extractors reading/writing binary data vs text

≡放荡痞女 提交于 2019-12-05 06:14:51
I've been trying to read up on iostreams and understand them better. Occasionally I find it stressed that inserters ( << ) and extractors ( >> ) are meant to be used in textual serialization. It's a few places, but this article is a good example: http://spec.winprog.org/streams/ Outside of the <iostream> universe, there are cases where the << and >> are used in a stream-like way yet do not obey any textual convention. For instance, they write binary encoded data when used by Qt's QDataStream : http://doc.qt.nokia.com/latest/qdatastream.html#details At the language level, the << and >>