Skip to main content

Posts

Showing posts with the label download

Download File Using jQuery

How can I prompt a download for a user when they click a link. For example, instead of: <a href="uploads/file.doc">Download Here</a> I could use: <a href="#">Download Here</a> $('a').click... //Some jquery to download the file This way, Google does not index my HREF's and private files. Can this be done with jQuery, if so, how? Or should this be done with PHP or something instead? Thanks! Source: Tips4all

Android download binary file problems

I am having problems downloading a binary file (video) in my app from the internet. In Quicktime, If I download it directly it works fine but through my app somehow it get's messed up (even though they look exactly the same in a text editor). Here is a example: URL u = new URL("http://www.path.to/a.mp4?video"); HttpURLConnection c = (HttpURLConnection) u.openConnection(); c.setRequestMethod("GET"); c.setDoOutput(true); c.connect(); FileOutputStream f = new FileOutputStream(new File(root,"Video.mp4")); InputStream in = c.getInputStream(); byte[] buffer = new byte[1024]; int len1 = 0; while ( (len1 = in.read(buffer)) > 0 ) { f.write(buffer); } f.close();

Get files from Jar which is on the repository without downloading the whole Jar from Java

I would like to access the jar file on the repository, search inside it for the certain files, retrieve those files and store them on my hard disc. I don't want to download the whole jar and then to search for it. So let's assume I have the address of the Jar. Can someone provide me with the code for the rest of the problem? public void searchInsideJar(final String jarUrl, final String artifactId, final String artifactVersion) { InputStream is = null; OutputStream outStream = null; JarInputStream jis = null; int i = 1; try { String strDirectory = "C:/Users/ilijab/" + artifactId +artifactVersion; // Create one directory boolean success = (new File(strDirectory)).mkdir(); if (success) { System.out.println("Directory: " + strDirectory + " created"); } is = new URL(jarUrl).openStream(); jis = new JarInputStream(is); while (true) { J