w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Czech characters display issue on WebClient download string
This works using (WebClient client = new WebClient()) { client.Encoding = Encoding.UTF8; string vysledek = client.DownloadString("http://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/denni_kurz.txt?date=13.09.2013"); var table = vysledek.Split(new char[] { ' ', ' ' }) .Select(line => line.Split('|').ToList()) .Skip(2) .ToList(); }

Categories : C#

How To Download Image by WebClient
I belive WebClient dont support the use of cache. You could try check the image size, if its diferent download, otherwise use the one you already downloaded. This code will get the image size, without downloading it: Dim wc As System.Net.WebClient = New System.Net.WebClient wc.OpenRead("http://example.com/ex.png") Dim bytes_total As Int64 = Convert.ToInt64(wc.ResponseHeaders("Content-Length"))

Categories : Vb.Net

WebClient login and download
One possible problem is that your login request is not successful. Try to inspect what is returned by the web server when client.UploadValues is called. Are you sure the fields are named email and password?

Categories : Vb.Net

Fastest way to download file on site using java
You are optimizing prematurely. The network bandwidth bottleneck is likely going to far outweigh any processing you are doing. You don't need to wrap the InputStream in a BufferedInputStream. You may want to favor larger read buffer sizes, but that may have minimal effect depending on the underlying implementation of the InputStream returned by the connection, kernel level buffering, etc. For a progress bar, take what you've read so far and divide it by connection.getContentLength(), but note that getContentLength() may return -1 if the length is unknown (it simply gives you the value of the Content-length header). As you're reading the data, pass the progress info along to whatever you choose to do to display it to the user.

Categories : Java

WebClient to download data from deployed web
why are you using new uri byte[] myDataBuffer = client.DownloadData((new Uri(strFileUrlToDownload))); // null exception here is an example taking directly from msdn WebClient client = new WebClient(); byte[] myDataBuffer = client.DownloadData(strFileUrlToDownload); http://msdn.microsoft.com/en-us/library/xz398a3f.aspx

Categories : C#

Using webclient to download images from deployed website
First, the WebClient class already has a method for this. Use something like client.DownloadFile(remoteUrl, localFilePath). See this link: WebClient.DownloadFile Method (String, String) Secondly, you will need to index the files you want to download on the server somehow. You can't just get a directory listing over HTTP and then loop through it. The web server will need to be configured to enable directory listing, or you will need a page to generate a directory listing. Then you will need to download the results of that page as a string using WebClient.DownloadString and parse it. A simple solution would be an aspx page that outputs a plaintext list of files in the directory you want to download. Finally, in the code you posted you're saving every single file you download as a file n

Categories : C#

webclient doesn't download the web page completely
Try this public static string GetHTMLDocument(string url) { var result = ""; using (var wc = new WebClient()) { result = wc.DownloadString(url); } return result; }

Categories : C#

How do I check if WebClient download is completed before I execute a function?
The DownloadStringAsync() method is returning before the string is downloaded because it's an asynchronous method. If you move the DoSomethingWithJson() method to your completed handlers then it will be called once the request is completed. You may want to add logic to the DoSomethingWithJson() method so that it only does it's work if all the variables it needs are populated (If indeed you need them all to be populated before you start doing anything else). WebClient Url1 = new WebClient(); Url1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Url1_DownloadStringCompleted); Url1.DownloadStringAsync(new Uri("http://example.com")); WebClient Url2 = new WebClient(); Url2.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Url2_DownloadStringCompleted); Url2.D

Categories : C#

getting source code of redirected http site via c# webclient
Welcome to the wonderful world of page scraping. The short answer is "you can't do that." Not in the general case, anyway, and certainly not with WebClient. The problem appears to be that some Javascript does the redirection. And since all WebClient does is download the page, it's not even going to download the Javascript. Much less parse and execute it. You might be able to do this by creating a program that uses the WebBrowser class. You can have it load the page. It should do the redirect and then you can inspect the result, which should be the page you were looking for. I haven't actually done this, but it does seem possible. Your other option is to fire up your Web browser's developer tools (like IE's F12 Developer Tools) and watch what's happening. You can then inspect the Javascri

Categories : C#

HtmlUnit use WebClient to download an image as base64 encoded DATA Uri
A couple of things to consider: The BASE64Encoder() generates a string that has a line break every 77 chars. Take that out using .replaceAll(" ? ",""). For that method also, it is better to retrieve the web page InputStream rather than the string. Also, to convert that to a byte array, I used a utility method (source and other options can be found here). Working source code: public static void main (String args[]) throws IOException { WebClient client = new WebClient(BrowserVersion.FIREFOX_3_6); UnexpectedPage imagePage = client.getPage("http://i.stack.imgur.com/9DdHc.jpg"); BASE64Encoder encoder = new BASE64Encoder(); String base64data = encoder.encode(inputStreamToByteArray(imagePage.getWebResponse().getContentAsStream())); System.out.println("<img src="data:i

Categories : Java

Frame Load Interrupted: Safari won't download a linked zip file from my Flash site
You could also let ActionScript do the downloading. If you add the following code you get a dialog box that lets you select a location to download your file and downloads it. btn_name.addEventListener(MouseEvent.CLICK,downloadFile); function downloadFile (evtObj:Event):void { var Location:URLRequest = new URLRequest(); Location.url = "http://www.example.com/image.jpg"; var fr:FileReference = new FileReference(); fr.download(request); }

Categories : Actionscript

How to download a string as a .csv file, without writing the string to a file and reading from the file?
This is because the browser is viewing the content-type you create and send with print "Content-Type:text/plain "; - as @Julian mentions you could try changing that line back or adding the line print "Content-Type:application/x-download "; after the text/plain line and see if this fixes things. Since that particular content-type may actually need a real file to to work with, you could try other content-types (see @Hunter McMillen's suggestion) since the browser may offer a download/save dialog in that case. You might need to add the following to fool the browser (and remove the text/csv): print "Content-Type:application/x-download "; print "Content-Disposition:attachment;filename=$ID ";

Categories : Perl

C++ libcurl -- download a txt file from ftp and save as a string
Instead of passing a callback function to libcurl that writes the retrieved data to a file, pass a function that appends the data to a string (untested): #include <iostream> #include <string> #include <curl/curl.h> static size_t my_write(void *buffer, size_t size, size_t nmemb, void *param) { std::string& text = *static_cast<std::string*>(param); size_t totalsize = size * nmemb; text.append(static_cast<char*>(buffer), totalsize); return totalsize; } int main() { std::string result; CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/KLAX.TXT"); /* Define our callback to get called w

Categories : C++

.Net WebClient fails for very long query string
See this here: What is the maximum possible length of a query string? Different software appears to accept different maximum length query strings, which is why I would guess firefox works according to that answer. I would suggest contacting the makers of the API to allow POST queries, that way you could have larger payloads and it would be more secure when using SSL.

Categories : Dotnet

Download a file on button click and send value to the download file as parameter
window.location.href = 'excel.php?param=123'; at the end of excel.php simply output excel file contents header("Content-Disposition: attachment; filename="excel.xls"); header("Content-Type: application/force-download"); readfile('excel.xls') die();

Categories : PHP

How hide a download url from our web site
If I understand the question, you're trying to let the user download a file from http://www.downloadsite.com/blablabla.png that appears to the user, in every sense, to be coming from http://www.mysite.com?link_id=12345. This is what I'd try: if (Request.Params["link_id"] == "12345") { Uri uri = new Uri("http://www.downloadsite.com/blablabla.png"); using (var wc = new WebClient()) using (var download = wc.OpenRead(uri)) using (var respStream = Response.OutputStream) download.CopyTo(respStream); }

Categories : C#

Is JRE used in IBM products different to the ones we download from Oracle site?
WTX uses it's own JRE. You can find it on the install dir of the designer. For example: C:Program FilesIBMWebSphere Transformation Extender X.Xjava Regards, B.

Categories : Java

Automate download data from web site using vb.net
I had written an article on this using ASP.NET MVC, it should help you : Introduction to Web Scraping with HttpWebRequest using ASP.NET MVC 3 Web Scrapping means parsing those pages to extract pieces of information in a structured way. It also refers to creating a programmatic interface, an API, that interacts with a site through an HTML interface meant for humans. Please dont think that your program will type in username and password in to thier respective textboxes and then the program will press the login button for you to go inside the website. Web Scraping does not happen in this manner. You need to study how the website POST the Login username and password and then using your code you need to do the same thing to get the cookie. At each step, rather on each page you ll need to se

Categories : Vb.Net

First Data Patament Gateway- No option to download 'digital certificate' (.PEM) file in Download Center
You can Download the Certificates using Internet Explorer Browser. The Firefox, Chrome and other browsers not support to download. Important thing is Use "111111111" as your Tax ID for your test account. For production stores you will be required to supply your actual SSN or Tax ID submitted in the merchant account boarding process.

Categories : PHP

Weird WebClient behavior: 1 computer hangs, others don't for same file
After hours of banging my head on the screen, a pleasant session with WireShark and several separate sessions with Fiddler, I found the answer. Sharing it here in case others have the same problem. It turns out that any use of HttpWebRequest prior would cause this behavior if the WebResponse object was not .Close()d properly. No matter if you create multiple WebClient or HttpWebRequest objects. They will all fail. The clue came from the following observation: watching the TCP back-and-forth in WireShark, it became clear that nothing was being sent to the server for the second request (the one that was failing). Why did this work with Fiddler running but not when it wasn't? I suspect that Fiddler is "playing nice" and forcibly closing the connections.

Categories : C#

Rails download http response/displayed site
To force it to download it, add :disposition => attachment to your send_file method. Source: Force a link to download an MP3 rather than play it?

Categories : Ruby On Rails

how to add error document for local site (where index is not in doc root) and live site both in one .htaccess file
In a single htaccess, you can't do this since it works identical to a <Directory> container. Additionally, the ErrorDocument directive doesn't have and conditionals. What you need to do is create a second htaccess file with only an error document directive, which will override the one declared in the document root. Everything else in the document root's htaccess file should still apply.

Categories : Apache

APK download failure if behind password protected site on stock browser
This looks to be a (~6-year old!!) bug in Android: https://code.google.com/p/android/issues/detail?id=1353 Apparently all we can do is star the issue. There are other hacky workarounds posted around the internet that you can find on your own, but I wouldn't recommend most of them as a general solution. Perhaps try changing the filename extension to be in all caps, as suggested here: http://www.digiblog.de/2011/04/android-and-the-download-file-headers/ So the line becomes: Content-Disposition: attachment; filename="SironaVideoSurvey.APK" If that doesn't work, I would just recommend that you tell your clients to use a different, non-stock (and non-Chrome!) browser. :/ Good luck.

Categories : Android

File download from URL stops when multiple clients try to download it
Your download code looks ok and I do not see any reason for a race condition, so without deeper analysis of your download code, I can tell you that this code (client side) is not the problem. It must be the server side which causes the problem, i.e. your webserver or a proxy or firewall which is in between. Moreover, maybe you should look at JNLP, which is a technology designed exactly for your problem of keeping an application always updated and checking this at startup.

Categories : Java

Automatically download an xml file from URI with download popup
The URI that you are using is probably wrong. You are using the URI that opens the popup page. The popup page should be doing another GET to the dynamically generated file. To automate this process, you should use a WebRequest to get the contents of the popup page. Scrape the contents of the page to get the actual URL to download the file. Then use the code you have written to download the file. var request = WebRequest.Create("PopupUrl"); var response = request.GetResponse(); string url = GetUrlFromResponseByRegExOrXMLParsing(); var client = new WebClient(); webClient.DownloadFile(url, filePath);

Categories : C#

how to download file in android download service
You can download any file using AsyncTask. downloadContent(); private void downloadContent() { DownloadFile downloadFile = new DownloadFile(); downloadFile.execute("http://somehost.com/file.mp3"); } // usually, subclasses of AsyncTask are declared inside the activity class. // that way, you can easily modify the UI thread from here private class DownloadFile extends AsyncTask<String, Integer, String> { @Override protected String doInBackground(String... sUrl) { try { URL url = new URL(sUrl[0]); URLConnection connection = url.openConnection(); connection.connect(); int fileLength = connection.getContentLength(); InputStream input = new BufferedInputStream( connection.g

Categories : Android

pgql/Hibernate File up/download - download size twice file size?
It looks like your library for connecting to PostgreSQL does not know how to decode the hex format for bytea. You could try changing your PostgreSQL setting for bytea_output to 'escape'. (If that works, it suggests your library is rather out of date.) I had the same problem with Perl's DBD::Pg, only to discover that I was using a much older version than I thought I was, and after updating it then it automatically did the correct thing regardless of bytea_output setting.

Categories : Hibernate

Java download to target (target can't be found) and 0 byte file download
You are using the transferFrom() method as a one-liner. However, I think you should check whether more data is available. From the API: An attempt is made to read up to count bytes from the source channel and write them to this channel's file starting at the given position. An invocation of this method may or may not transfer all of the requested bytes; whether or not it does so depends upon the natures and states of the channels. Fewer than the requested number of bytes will be transferred if the source channel has fewer than count bytes remaining, or if the source channel is non-blocking and has fewer than count bytes immediately available in its input buffer. A similar question was also posted that may help you.

Categories : Java

Does Azure Point-to-Site or Site-to-Site VPN support cloud services?
I haven't tried personally, but you should be able to do just that by joining your cloud service to a virtual network. See this article for details on how to do this: http://convective.wordpress.com/2012/08/26/windows-azure-cloud-services-and-virtual-networks/.

Categories : Azure

Connect azure web site to on-premise database over site-to-site vpn
Azure Web Sites do not support the Azure Virtual Network (as of 8/22/2013); http://www.windowsazure.com/en-us/manage/services/web-sites/choose-web-app-service/ You will need to create a cloud service deployment instead if you would like to use Virtual Network and access the on-premises database. Once that is done and your firewall is properly configured, it is like you say just a connection string.

Categories : Database

Using Dart to Download a PNG File (Binary File) and displaying it not working
The problem is this line: Blob blob = new Blob(request.response); The Blob constructor expects a List instead of another Blob (which request.response is in your use case): factory Blob(List blobParts, [String type, String endings]) Just delete the line, and directly call reader.readAsDataUrl(request.response), and it should work.

Categories : Dart

firefox: download javascript file using the file protocol?
Doesn't seem to be related to programming... just press Ctrl+S If you want to force download prompt programmatically: function downloadPrompt(url) { var a = document.createElement("a"); a.href = url; a.download = a.href.substr(a.href.lastIndexOf("/") + 1); document.body.appendChild(a); a.click(); document.body.removeChild(a); } demo http://jsfiddle.net/Sbp5M/ only seems to be working in Google Chrome though.

Categories : Javascript

File download error when file has no content or size is 0
I'm guessing here, not being able to see the rest of the code. I am assuming that when you are trying to download a file of 0bytes, an error is occurring so i would maybe write something like if(!force_download($fileoriginalname, $data)) { \ the file download failed. handle this error }

Categories : PHP

download mp3 file through xmlhttprequest and save it as a file somewhere for upload later
thi is the function that loads and mp3 in your case using xhr , covertsit to base64 an then executes a function with the base64 file string var xhrfile=function(i,f){ var c=new XMLHttpRequest(); c.open('GET',i); c.responseType='arraybuffer'; //c.onprogress=function(e){var perc=Math.round((e.loaded/e.total)*100)+' of 100'}; c.onload=function(e){ var u8=new Uint8Array(this.response),ic=u8.length,bs=[]; while(ic--){bs[ic]=String.fromCharCode(u8[ic]);}; f('data:audio/mpeg;base64,'+btoa(bs.join(''))); }; c.send(); } usage: xhrfile('http://domain.com/your.mp3',filefunc) now as you want to save the file use indexedDB,websql,localstorage,fileApi or whatever you want.... it's a string now. consider that this mentioned saving possibilities have filesize limitations. you can al

Categories : Javascript

Node.js: stream remote file to file download
var request = require("request"); expressjs_app.get("/file_url", function(req, res){ request.get('remote_file_url').pipe(res); }); if you are using http module and not express js then replace the 2nd part with: var http = require("http"); http.createServer(function (req, res) { if (req.url === '/file_url') { request.get('remote_file_url').pipe(res); } });

Categories : Javascript

File Download Gives Error "File if broken" on IOS (works on PC)
I have a PHP script which is downloading file after it is created. My bet is you're using HTML to create the file, and giving it a .doc extension to make it look like a Word document. While this is totally okay and supported by all versions of Word AFAIK, a 3rd party viewer program like on an iPad may be more strict. A HTML based file is technically not a Word document, and the viewer may not be equipped to parse it accordingly. You may need to resort to generating a real .doc file.

Categories : PHP

How to download an image file via HTTP into a temp file?
There are more api-friendly libraries than Net::HTTP, for example httparty: require "httparty" File.open("/tmp/my_file.jpg", "wb") do |f| f.binmode # @MariusButuc's suggestion f.write HTTParty.get("http://tinyurl.com/lvtxz6v").parsed_response end

Categories : Ruby

C# Download html page to a string AS IS?
You just have to force the encoding to be the same on the webpage you request. With WebClient you do the following: using(WebClient webClient = new WebClient()) { webClient.Encoding = Encoding.UTF8; string s = webClient.DownloadString("http://wwww.li.ru"); } With HttpWebResponse/Request: HttpWebRequest webRequest = HttpWebRequest.CreateHttp("http://www.li.ru"); using (HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse()) { using (Stream resStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(resStream, Encoding.UTF8); return reader.ReadToEnd(); } } Edit: Just extend the fixed encoding to the following code: var enc = Encoding.Default; if (!string.IsNullOrEmpty(response.CharacterSet)) { var charSet =

Categories : C#

download file from ftp using php file size issue
This is my code for get all files from link share ftp <?php session_start(); $i = $_REQUEST['i']; if($i==""){ $i=0; $source_dir=("linkshare"); $source_folder=dir($source_dir); while($files_list=$source_folder->read()) { if ($files_list!= "." && $files_list!= "..") { $pat="linkshare/"; unlink($pat.$files_list); } if($files_list!="") { $pat="linkshare/"; unlink($pat.$files_list); } } } $destinationnameeeeee = "linkshare/"; ini_set("max_execution_time",300000000000000000); $ftp_server = ''; //ftp server name $ftp_user_name = ''; //ftp user name $ftp_user_pass = ''; //ftp user password $conn_id = ftp_connect($ftp_server)

Categories : PHP

Download string from URL using a portable class library (PCL)
Install the NuGet packages: Microsoft.Bcl.Async, which adds async/await support to PCLs. Microsoft.Net.Http, which adds HttpClient support to PCLs. Then you can do it the easy way: var client = new HttpClient(); var data = await client.GetStringAsync(url);

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.