Download a file by jQuery.Ajax

I have a Struts2 action in the server side for file downloading. <action name=”download” class=”com.xxx.DownAction”> <result name=”success” type=”stream”> <param name=”contentType”>text/plain</param> <param name=”inputName”>imageStream</param> <param name=”contentDisposition”>attachment;filename={fileName}</param> <param name=”bufferSize”>1024</param> </result> </action> However when I call the action using the jQuery: $.post( “/download.action”,{ para1:value1, para2:value2 …. },function(data){ console.info(data); } ); in Firebug I see the data is retrieved with … Read more

Do I need Content-Type: application/octet-stream for file download?

The HTTP standard says: If this header [Content-Disposition: attachment] is used in a response with the application/octet-stream content-type, the implied suggestion is that the user agent should not display the response, but directly enter a `save response as…’ dialog. I read that as Content-Type: application/octet-stream Content-Disposition: attachment But I would have thought that Content-Type would … Read more

Download large file in python with requests

Requests is a really nice library. I’d like to use it for downloading big files (>1GB). The problem is it’s not possible to keep whole file in memory; I need to read it in chunks. And this is a problem with the following code: import requests def DownloadFile(url) local_filename = url.split(“https://stackoverflow.com/”)[-1] r = requests.get(url) f … Read more

How to trigger a file download when clicking an HTML button or JavaScript

This is crazy but I don’t know how to do this, and because of how common the words are, it’s hard to find what I need on search engines. I’m thinking this should be an easy one to answer. I want a simple file download, that would do the same as this: <a href=”https://stackoverflow.com/questions/11620698/file.doc”>Download!</a> But … Read more

Download single files from GitHub

What are some tips on downloading a single file from a GitHub repo? I don’t want the URL for displaying the raw file; in the case of binaries, there’s nothing. http://support.github.com/discussions/feature-requests/41-download-single-file Is it even possible to use GitHub as a “download server”? If we decide to switch to Google Code, is the mentioned functionality presented … Read more

How do I measure request and response times at once using cURL?

I have a web service that receives data in JSON format, processes the data, and then returns the result to the requester. I want to measure the request, response, and total time using cURL. My example request looks like: curl -X POST -d @file server:port and I currently measure this using the time command in … Read more

Download a file with Android, and showing the progress in a ProgressDialog

I am trying to write a simple application that gets updated. For this I need a simple function that can download a file and show the current progress in a ProgressDialog. I know how to do the ProgressDialog, but I’m not sure how to display the current progress and how to download the file in … Read more