Search Results

Search found 4324 results on 173 pages for 'stream'.

Page 12/173 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Stream PDF to another local App

    - by Nathan
    Hi, I'm currently trying to optimize a small firefox extension that will grab a pdf off the current document and send it to a port that another local application is listening on. Right now it uses a terrifying hackjob of cache viewer. The way I'm getting it is loading the cache, searching through it using the current URL and grabbing the file and saving it to a temp directory. Then I stream the file in, delete the temp, and send it through the socket. Now, my new design, ideally I'd want to build it from scratch and cut out saving it to the local machine at all, and just stream it through the socket. I've been looking at doing something like, //check page to ensure its a pdf //init in/out streams //stream through sock //flush Now, this would be vastly superior to the 400 line hacked up mess I have now, but I'm new to building FF extensions, and after reading a lot about URIs and the file streaming and such I'm probably more confused than when I started trying to fix this three hours ago. I'm okay with sending things through the sockets and whatnot, I understand that, I'm mainly confused about what multitude of interfaces I want to use. Gah! Thanks! Also, long time reader, first time poster!

    Read the article

  • App-Engine Parse a UrlFetch UTF-8 encoded stream

    - by Davidrd91
    I am trying to parse an XML from a URL using the xml.sax parser. I know there are other libraries to use but coming from Java this is the one I am most familiar with and seems the least complicated to me. The code I'm using to parse is as follows: parser = xml.sax.make_parser() handler = MangaHandler() parser.setContentHandler(handler) url = urlfetch.Fetch('http://www.mangapanda.com/alphabetical', allow_truncated = False, follow_redirects = False, deadline = False) xml.sax.parseString(url.content, handler) This returns a SaxException (invalid token) once the parser reaches the first & sign: SAXParseException: <unknown>:582:34: not well-formed (invalid token) Because urlfetch returns a string and not a stream I cannot use the parse() (which only works with streams) and am left to use parseString() instead. To see if parsing as a stream would fix this I tried: parser.parse(io.StringIO(url.content).encode('utf-8')) but this returns: TypeError: initial_value must be unicode or None, not str I have also tried to use the urllib2 libraries which do return a stream instead of urlfetch but the file is too large and is automatically truncated, leaving me with missing data. Any Sort of work-around for this would be greatly appreciated as I've spent days getting around one obstacle just to be stopped by another.

    Read the article

  • overloaded stream insertion operator with a vector

    - by Julz
    hi, i'm trying to write an overloaded stream insertion operator for a class who's only member is a vector. i dont really know what i'm doing. (lets make that clear) it's a vector of "Points" which is a struct containing two doubles. i figure what i want is to insert user input (a bunch of doubles) into a stream that i then send to a modifier method? i keep working off other stream insertion examples such as... std::ostream& operator<< (std::ostream& o, Fred const& fred) { return o << fred.i_; } but when i try a similar..... istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr.vertices; return inStream; } i get an error "no match for operator etc etc. if i leave off the .vertices it compiles but i figure it's not right? (vertices is the name of my vector ) and even if it is right, i dont actually know what syntax to use in my driver to use it? also not %100 on what my modifier method needs to look like. here's my Polygon class //header #ifndef POLYGON_H #define POLYGON_H #include "Segment.h" #include <vector> class Polygon { friend std::istream & operator >> (std::istream &inStream, Polygon &vertStr); public: //Constructor Polygon(const Point &theVerts); //Default Constructor Polygon(); //Copy Constructor Polygon(const Polygon &polyCopy); //Accessor/Modifier methods inline std::vector<Point> getVector() const {return vertices;} //Return number of Vector elements inline int sizeOfVect() const {return (int) vertices.capacity();} //add Point elements to vector inline void setVertices(const Point &theVerts){vertices.push_back (theVerts);} private: std::vector<Point> vertices; }; #endif //Body using namespace std; #include "Polygon.h" // Constructor Polygon::Polygon(const Point &theVerts) { vertices.push_back (theVerts); } //Copy Constructor Polygon::Polygon(const Polygon &polyCopy) { vertices = polyCopy.vertices; } //Default Constructor Polygon::Polygon(){} istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr; return inStream; } any help greatly appreciated, sorry to be so vague, a lecturer has just kind of given us a brief example of stream insertion then left us on our own thanks. oh i realise there are probably many other problems that need fixing

    Read the article

  • overloaded stream insetion operator with a vector

    - by julz666
    hi, i'm trying to write an overloaded stream insertion operator for a class who's only member is a vector. i dont really know what i'm doing. (lets make that clear) it's a vector of "Points" which is a struct containing two doubles. i figure what i want is to insert user input (a bunch of doubles) into a stream that i then send to a modifier method? i keep working off other stream insertion examples such as... std::ostream& operator<< (std::ostream& o, Fred const& fred) { return o << fred.i_; } but when i try a similar..... istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr.vertices; return inStream; } i get an error "no match for operator etc etc. if i leave off the .vertices it compiles but i figure it's not right? (vertices is the name of my vector ) and even if it is right, i dont actually know what syntax to use in my driver to use it? also not %100 on what my modifier method needs to look like. here's my Polygon class //header #ifndef POLYGON_H #define POLYGON_H #include "Segment.h" #include <vector> class Polygon { friend std::istream & operator >> (std::istream &inStream, Polygon &vertStr); public: //Constructor Polygon(const Point &theVerts); //Default Constructor Polygon(); //Copy Constructor Polygon(const Polygon &polyCopy); //Accessor/Modifier methods inline std::vector<Point> getVector() const {return vertices;} //Return number of Vector elements inline int sizeOfVect() const {return (int) vertices.capacity();} //add Point elements to vector inline void setVertices(const Point &theVerts){vertices.push_back (theVerts);} private: std::vector<Point> vertices; }; #endif //Body using namespace std; #include "Polygon.h" // Constructor Polygon::Polygon(const Point &theVerts) { vertices.push_back (theVerts); } //Copy Constructor Polygon::Polygon(const Polygon &polyCopy) { vertices = polyCopy.vertices; } //Default Constructor Polygon::Polygon(){} istream & operator >> (istream &inStream, Polygon &vertStr) { inStream >> ws; inStream >> vertStr; return inStream; } any help greatly appreciated, sorry to be so vague, a lecturer has just kind of given us a brief example of stream insertion then left us on our own thanks. oh i realise there are probably many other problems that need fixing

    Read the article

  • How to encrypt and save a binary stream after serialization and read it back?

    - by Anindya Chatterjee
    I am having some problems in using CryptoStream when I want to encrypt a binary stream after binary serialization and save it to a file. I am getting the following exception System.ArgumentException : Stream was not readable. Can anybody please show me how to encrypt a binary stream and save it to a file and deserialize it back correctly? The code is as follows: class Program { public static void Main(string[] args) { var b = new B {Name = "BB"}; WriteFile<B>(@"C:\test.bin", b, true); var bb = ReadFile<B>(@"C:\test.bin", true); Console.WriteLine(b.Name == bb.Name); Console.ReadLine(); } public static T ReadFile<T>(string file, bool decrypt) { T bObj = default(T); var _binaryFormatter = new BinaryFormatter(); Stream buffer = null; using (var stream = new FileStream(file, FileMode.OpenOrCreate)) { if(decrypt) { const string strEncrypt = "*#4$%^.++q~!cfr0(_!#$@$!&#&#*&@(7cy9rn8r265&$@&*E^184t44tq2cr9o3r6329"; byte[] dv = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}; CryptoStream cs; DESCryptoServiceProvider des = null; var byKey = Encoding.UTF8.GetBytes(strEncrypt.Substring(0, 8)); using (des = new DESCryptoServiceProvider()) { cs = new CryptoStream(stream, des.CreateEncryptor(byKey, dv), CryptoStreamMode.Read); } buffer = cs; } else buffer = stream; try { bObj = (T) _binaryFormatter.Deserialize(buffer); } catch(SerializationException ex) { Console.WriteLine(ex.Message); } } return bObj; } public static void WriteFile<T>(string file, T bObj, bool encrypt) { var _binaryFormatter = new BinaryFormatter(); Stream buffer; using (var stream = new FileStream(file, FileMode.Create)) { try { if(encrypt) { const string strEncrypt = "*#4$%^.++q~!cfr0(_!#$@$!&#&#*&@(7cy9rn8r265&$@&*E^184t44tq2cr9o3r6329"; byte[] dv = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF}; CryptoStream cs; DESCryptoServiceProvider des = null; var byKey = Encoding.UTF8.GetBytes(strEncrypt.Substring(0, 8)); using (des = new DESCryptoServiceProvider()) { cs = new CryptoStream(stream, des.CreateEncryptor(byKey, dv), CryptoStreamMode.Write); buffer = cs; } } else buffer = stream; _binaryFormatter.Serialize(buffer, bObj); buffer.Flush(); } catch(SerializationException ex) { Console.WriteLine(ex.Message); } } } } [Serializable] public class B { public string Name {get; set;} } It throws the serialization exception as follows The input stream is not a valid binary format. The starting contents (in bytes) are: 3F-17-2E-20-80-56-A3-2A-46-63-22-C4-49-56-22-B4-DA ...

    Read the article

  • Getting access to a binary response byte-by-byte in classic asp/JScript

    - by user89691
    I asked this question a few days ago but it seems to have gone cold fairly quickly. What I want to do is pretty simple and I can't believe someone hasn't figured it out. Solution needs to be JScript classic ASP. I am reading a file from a remote server and I want to process that (binary) file on my server and spit the results back to the client as XML. Here's a simplified version of what I am trying to do. This code runs, or will if the URL is filled in for your site. This test file is readbin.asp. It reads a file called test.bin, and writes the result to a stream. I used a stream because that makes it easier to read the file and parse the contents. Basically I want to: while not end of stream read byte from stream process byte here is readbin.asp: <%@ LANGUAGE = JScript %> <% var url = "http:// (... your URL to the file test.bin goes here...) " ; var xmlhttp = Server.CreateObject ("MSXML2.ServerXMLHTTP") ; xmlhttp.open ("GET", url, false) ; xmlhttp.send () ; var BinaryInputStream = Server.CreateObject ("ADODB.Stream") ; BinaryInputStream.Type = 1 ; // binary BinaryInputStream.Open ; BinaryInputStream.Write (xmlhttp.responseBody) ; BinaryInputStream.Position = 0 ; Response.Write ("BinaryInputStream.size = " + BinaryInputStream.size + "<br>") ; Response.Write ("BinaryInputStream = " + BinaryInputStream + "<br>") ; var ByteValue = BinaryInputStream.read (1) ; Response.Write ("ByteValue = " + ByteValue + "<br>") ; Response.Write ("typeof (ByteValue) = " + typeof (ByteValue) + "<br>") ; %> My problem is: how do I get ByteValue as a number 0..255? typeof (ByteValue) is "unknown". Ord?? Byte()?? Asc?? Chr??

    Read the article

  • .NET: Problems creating email attachment from MemoryStream.

    - by David
    Hi all I'm using the following method to create an attachment from a MemoryStream: public void AddAttachment(Stream stream, string filename, string mimeType) { byte[] buffer = ((MemoryStream) stream).GetBuffer(); Attachment attachment = new Attachment(stream, filename, mimeType); _mail.Attachments.Add(attachment); } Note that the first line is not necessary isn't necessary for the attachment functionality, it's just useful to have the byte[] handy during debugging so that I can see how big it is. (It generally has around 80,000 elements.) The code runs fine and the email is sent. When Outlook receives the email, in the Inbox it displays the attachment symbol, but when you go into the email the attachment isn't there. Unfortunately I don't have access to the mail server to find out more about the email, e.g. what the attachment looks like, its size etc. Can anyone suggest what properties of the MemoryStream argument might tell me if it is in some way invalid for attachment? Or think of anything else I might try? Thank you. David

    Read the article

  • Combining the streams:Web application

    - by Surendra J
    This question deals mainly with streams in web application in .net. In my webapplication I will display as follows: bottle.doc sheet.xls presentation.ppt stackof.jpg Button I will keep checkbox for each one to select. Suppose a user selected the four files and clicked the button,which I kept under. Then I instantiate clasees for each type of file to convert into pdf, which I wrote already and converted them into pdf and return them. My problem is the clases is able to read the data form URL and convert them into pdf. But I don't know how to return the streams and merge them. string url = @"url"; //Prepare the web page we will be asking for HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; request.ContentType = "application/mspowerpoint"; request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0"; //Execute the request HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //We will read data via the response stream Stream resStream = response.GetResponseStream(); //Write content into the MemoryStream BinaryReader resReader = new BinaryReader(resStream); MemoryStream PresentaionStream = new MemoryStream(resReader.ReadBytes((int)response.ContentLength)); //convert the presention stream into pdf and save it to local disk. But I would like to return the stream again. How can I achieve this any Ideas are welcome.

    Read the article

  • IOException reading from HttpWebResponse response stream over SSL

    - by Lawrence Johnston
    I get the following exception when attempting to read the response from my HttpWebRequest: System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream. at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.IO.StreamReader.ReadBuffer() at System.IO.StreamReader.ReadToEnd() ... My code functions without issue when using http. I am talking to a third-party device; I do not have access to the server code. My code is as follows: private string MakeRequest() { // Disable SSL certificate verification per // http://www.thejoyofcode.com/WCF_Could_not_establish_trust_relationship_for_the_SSL_TLS_secure_channel_with_authority.aspx ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); Uri uri = new Uri("https://mydevice/mypath"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = WebRequestMethods.Http.Get; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { using (StreamReader sr = new StreamReader(responseStream.)) { return sr.ReadToEnd(); } } } } Does anybody have any thoughts about what might be causing it?

    Read the article

  • Non-blocking read on a stream in python.

    - by Mathieu Pagé
    Hi, I'm using the subprocess module to start a subprocess and connect to it's output stream (stdout). I want to be able to execute non-blocking reads on its stdout. Is there a way to make .readline non-bloking or to check if there is data on the stream before I invoke .readline? I'd like this to be portable or at least work under Windows and Linux. here is how I do it for now (It's blocking on the .readline if no data is avaible): p = subprocess.Popen('myprogram.exe', stdout = subprocess.PIPE) str = p.stdout.readline() Thanks for your help.

    Read the article

  • RAR password recovery on GPU using ATI Stream processor

    - by Wajdy Essam
    Hello, I'm newbie in GPU programming , and i work on brute force RAR Password Recovery on ATI Stream Processor using brook+ language, but i see that the kernel written in brook+ language doesn't allow any calling to normal functions (except kernel functions) , my questions is : 1) how to use unrar.dll (to unrar archive files) API in this situation? and is this the only way to program RAR password recovery? 2) what about crack and ElcomSoft software that use GPU , how they work ? 3) what exactly the role for the function work inside GPU (ATI Stream processor or CUDA) in this program? 4) is nVidia/CUDA technology is easier/more flexible than ATI/brook+ language ?

    Read the article

  • file_get_contents() returns "failed to open stream" when used with Facebook access_token flow

    - by TMC
    file_get_contents() is returning "failed to open stream" when I call it on a Facebook oAuth access_token URL. Warning: file_get_contents(https://graph.facebook.com/oauth/access_token?client_id=XXXXX&redirect_uri=http://mydomain.com/fb/callback3.php&client_secret=xxxx&code=YYYY) [function.file-get-contents]: failed to open stream: No error in E:\\htdocs\fb\callback3.php on line 5 (I have removed ClientID, clientSecret and the oAuth Code). If I try to manually hit the Facebook access_token URL that my code is attempting to fetch, I get an actual payload returned in the browser: access_token=XYZ&expires=6508 (where XYZ is the access token) So for some reason, there is a problem with the access_token URL specifically when used with file_get_contents(). At first, I thought it was a security issue with my webhoster, but I have verified with phpinfo() that allow url open is indeed allowed. I have also tried this code and verified it works: $foo = file_get_contents('http://google.com'); echo $foo Anyone have any ideas why file_get_contents() is failing with the Facebook access_token URL?

    Read the article

  • Song search and stream preview API

    - by teepusink
    Hi, Is there an API where I can search for a song, and then stream the preview of the song on my site? Looked into Amazon MP3, but I can't seem to find an API for Amazon MP3. Also looked into last.fm Track.Search api, but seems like the return value doesn't seem to give the actual filename. (i.e mp3 etc), which means I can't stream it on my site. Please let me know if there are other different APIs I can use as well. Thanks, Tee

    Read the article

  • HttpClient response handler always returns closed stream

    - by Alex Ciminian
    I'm new to Java development so please bear with me. Also, I hope I'm not the champion of tl;dr :). I'm using HttpClient to make requests over Http (duh!) and I'd gotten it to work for a simple servlet that receives an URL as a query string parameter. I realized that my code could use some refactoring, so I decided to make my own HttpResponseHandler, to clean up the code, make it reusable and improve exception handling. I currently have something like this: public class HttpResponseHandler implements ResponseHandler<InputStream>{ public InputStream handleResponse(HttpResponse response) throws ClientProtocolException, IOException { int statusCode = response.getStatusLine().getStatusCode(); InputStream in = null; if (statusCode != HttpStatus.SC_OK) { throw new HttpResponseException(statusCode, null); } else { HttpEntity entity = response.getEntity(); if (entity != null) { in = entity.getContent(); // This works // for (int i;(i = in.read()) >= 0;) System.out.print((char)i); } } return in; } } And in the method where I make the actual request: HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(target); ResponseHandler<InputStream> httpResponseHandler = new HttpResponseHandler(); try { InputStream in = httpclient.execute(httpget, httpResponseHandler); // This doesn't work // for (int i;(i = in.read()) >= 0;) System.out.print((char)i); return in; } catch (HttpResponseException e) { throw new HttpResponseException(e.getStatusCode(), null); } The problem is that the input stream returned from the handler is closed. I don't have any idea why, but I've checked it with the prints in my code (and no, I haven't used them both at the same time :). While the first print works, the other one gives a closed stream error. I need InputStreams, because all my other methods expect an InputStream and not a String. Also, I want to be able to retrieve images (or maybe other types of files), not just text files. I can work around this pretty easily by giving up on the response handler (I have a working implementation that doesn't use it), but I'm pretty curious about the following: Why does it do what it does? How do I open the stream, if something closes it? What's the right way to do this, anyway :)? I've checked the docs and I couldn't find anything useful regarding this issue. To save you a bit of Googling, here's the Javadoc and here's the HttpClient tutorial (Section 1.1.8 - Response handlers). Thanks, Alex

    Read the article

  • How to stream video content in asp.net?

    - by Kon
    Hi, I have the following code which downloads video content: WebRequest wreq = (HttpWebRequest)WebRequest.Create(url); using (HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse()) using (Stream mystream = wresp.GetResponseStream()) { using (BinaryReader reader = new BinaryReader(mystream)) { int length = Convert.ToInt32(wresp.ContentLength); byte[] buffer = new byte[length]; buffer = reader.ReadBytes(length); Response.Clear(); Response.Buffer = false; Response.ContentType = "video/mp4"; //Response.BinaryWrite(buffer); Response.OutputStream.Write(buffer, 0, buffer.Length); Response.End(); } } But the problem is that the whole file downloads before being played. How can I make it stream and play as it's still downloading? Or is this up to the client/receiver application to manage?

    Read the article

  • iPhone Live Video Stream Media Player

    - by happyhammer83
    I'm hoping to make an app that streams live video that has a view placed on top with labels and a button on it. From my research and testing of the http video streaming feature (available since iPhone 3.0 OS), it seems that you create a webview that points to the index html that contains the converted video stream, and this displays as a quicktime video in the app. This means that I don't have control over the Media Player that is opened. Does anyone know how you can control this? I know that the Apple's MoviePlayer sample code shows you how to place views on top of a MediaPlayer video, but how can this be done with a http live stream? Thanks in advance.

    Read the article

  • FBConnect stream.publish with iphone unknown response?

    - by Tom G
    Hi All, I am using stream.publish to publish some info to a users wall. This all works fine. I am not using FBStreamDialog because i do not want the user to be able to edit the message..... So i have set up my own UI. It all works fine and the stream is published to the users wall, the only issue is that i do not understand the result obtained from the delegate method: - (void)request:(FBRequest*)request didLoad:(id)result { NSLog(@"result = %@", result); } I need to understand what the result is telling me so that i can handle any errors. Currently the following is being printed in the console but i do not know what this means: result = 100000874992250_117813161591916 Any help or advice regarding this issue would be highly appreciated. Thanks Tom

    Read the article

  • Parsing XML stream in ASP.NET 3.5

    - by Ranjit
    Hi All, I am trying to build an ASP.NET 3.5 application based on XML streams from a legacy systems. My issue is once I get the XML I have to built menus and sub menus from the XML as well filter data(XML stream) based on the menu selection without making roundtrip to the Data store(legacy system). Right now I have a DAL which will get the XML stream in the form of XDocument.I was able to built the first level Menu Items, but not the sub Menu Items based on the selection in the Main Menu and then the final content based on the sub menu selection, all this without making a round trip. Is there a way to do this in-memory. Please suggest. thank you. Ranjit

    Read the article

  • file_get_contents() returns "failed to open stream" when hitting HTTPS

    - by TMC
    file_get_contents() is returning "failed to open stream" when I call it on an HTTPS URL. Warning: file_get_contents(https://google.com) [function.file-get-contents]: failed to open stream: No error in E:\\htdocs\callback3.php on line 5 Same call will work with a non-SSL URL. At first, I thought it was a security issue with my webhoster, but I have verified with phpinfo() that allow url open is indeed allowed. I have also tried this code and verified it works: Anyone have any ideas why file_get_contents() is failing with an HTTPS URL? update: People correctly pointed out this was an HTTPS issue. My webhoster claims this should work, and has no idea how to resolve this. Anyone have specific directions I can give them for their IIS7 setup?

    Read the article

  • What is PHP for C# ReadBytes(stream langth)?

    - by Ole Jak
    What is PHP for C# (asuming we open some local (on server) file instead of OpenFileDialog private const int HEADER_LENGTH = 13; stream = File.OpenRead(openFileDialog.FileName); header = ReadBytes(stream, HEADER_LENGTH); And will we be able to do something like this in PHP as a next step private const byte SIGNATURE1 = 0x46; private const byte SIGNATURE2 = 0x4C; private const byte SIGNATURE3 = 0x56; if ((SIGNATURE1 != header[0]) || (SIGNATURE2 != header[1]) || (SIGNATURE3 != header[2])) throw new InvalidDataException("Not a valid FLV file!.");

    Read the article

  • Parameter is not valid when getting image from stream

    - by duka1
    Hi guys, I have this code: MemoryStream ms = new MemoryStream(newbytes, 0, newbytes.Length); ms.Position = 0; ms.Write(newbytes, 0, newbytes.Length); Image img = Image.FromStream(ms); img.Save(@"C:\Users\gsira\Pictures\Blue hills5.jpg"); I get this error at the Image.FromStream(ms) call: System.ArgumentException: Parameter is not valid. at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateIma How can I resolve this? A couple of links which solve this problem (one on an MSDN thread) are broken so I am lost.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >