file-uri

making json/jsonp xhr requests on the file: protocol

微笑、不失礼 提交于 2019-12-04 13:49:50
I'm writing a javascript app that will be hosted on a file: protocol (ie: the application is just a folder of html, css, and javascript sitting someplace on my hard drive). When I try normal XHR requests they fail because of the same origin policy afaict. So my question is this, what's the best way to request json/jsonp files with an app as described above? Note: So far I've got all of my jsonp files using a hard-coded callback functions, but I'd like to be able to use dynamic callback functions for these requests.. is there a way to do this? This is kind of a hatchet job, but it will get you

How to use file protocol to access a directory on local system?

点点圈 提交于 2019-12-03 13:39:07
like /usr/local ? I tried file:///usr/local but failed [root@www2 robot]# cd file:///usr/local -bash: cd: file:///usr/local: No such file or directory If you have a requirement to be able to access generic URLs from your shell, try using curl as a replacement for your cat: curl file:///path/to/file.txt curl http://www.domain.com/file.txt But as other posters have pointed out, the shell itself doesn't understand URLs. If you have to deal with file:///usr/local on the command line, you could just remove the "file://" part. And do then a normal your command, e.g.: echo "file:///usr/local/" | sed

How to convert Windows path to file: URL, in a batch file, suitable for SVN command line use

断了今生、忘了曾经 提交于 2019-12-01 08:30:52
In a Windows-based SVN installation (using CollabNet Subversion Edge), I have a post-commit hook batch file where I construct a repository folder name, and I need to call svnsync with a file: URL pointing to that Windows folder. The question now is: How can I convert a Windows folder or file name to a file: URL, in such a way that that URL is at least acceptable for the SVN command line tools? In a batch file, if the variable FILE_OR_FOLDER_NAME contains the (absolute or relative, local or UNC, with or without spaces, existing or not existing) Windows file or directory name, then the following

How to launch a file protocol URL with an anchor from Java?

拟墨画扇 提交于 2019-11-30 18:13:20
From a Java program, I need to launch the default browser on a local HTML file, pointed to an anchor inside the file. In Java SE 6, the java.awt.Desktop.browse method will open the file, but will not honor the anchor, so something like the following opens the file at the top, but does not page the browser to the anchor: Desktop.getDesktop("file:///C:/foo/bar.html#anchor"); Sun says here http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6477862 that anchors are not supported in the file URI protocol. Does anyone have a better answer? I can use Java SE 6. I would be OK with a Windows only

Converting file:// scheme to content:// scheme

时光总嘲笑我的痴心妄想 提交于 2019-11-30 15:25:58
问题 I am running to the problem with using Droid X's Files app and Astro file manager to select an image file. This two apps return the selected image with the scheme "file://" while Gallery returns the image with the scheme "content://". How do I convert the first schema to the second. Or how do I decode the image with the second format? 回答1: You probably want to convert content:// to file:// For gallery images, try something like this: Uri myFileUri; Cursor cursor = context.getContentResolver()

Converting file:// scheme to content:// scheme

纵然是瞬间 提交于 2019-11-30 14:36:43
I am running to the problem with using Droid X's Files app and Astro file manager to select an image file. This two apps return the selected image with the scheme "file://" while Gallery returns the image with the scheme "content://". How do I convert the first schema to the second. Or how do I decode the image with the second format? You probably want to convert content:// to file:// For gallery images, try something like this: Uri myFileUri; Cursor cursor = context.getContentResolver().query(uri,new String[]{android.provider.MediaStore.Images.ImageColumns.DATA}, null, null, null); if(cursor

How to launch a file protocol URL with an anchor from Java?

房东的猫 提交于 2019-11-30 01:55:09
问题 From a Java program, I need to launch the default browser on a local HTML file, pointed to an anchor inside the file. In Java SE 6, the java.awt.Desktop.browse method will open the file, but will not honor the anchor, so something like the following opens the file at the top, but does not page the browser to the anchor: Desktop.getDesktop("file:///C:/foo/bar.html#anchor"); Sun says here http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6477862 that anchors are not supported in the file URI

Java : File.toURI().toURL() on Windows file

爷,独闯天下 提交于 2019-11-28 20:38:39
The system I'm running on is Windows XP, with JRE 1.6. I do this : public static void main(String[] args) { try { System.out.println(new File("C:\\test a.xml").toURI().toURL()); } catch (Exception e) { e.printStackTrace(); } } and I get this : file:/C:/test%20a.xml How come the given URL doesn't have two slashes before the C: ? I expected file://C:... . Is it normal behaviour? EDIT : From Java source code : java.net.URLStreamHandler.toExternalForm(URL) result.append(":"); if (u.getAuthority() != null && u.getAuthority().length() > 0) { result.append("//"); result.append(u.getAuthority()); } It

URI scheme is not “file”

懵懂的女人 提交于 2019-11-28 12:00:33
I get the exception: "URI scheme is not file" What I am doing is trying to get the name of a file and then save that file (from another server) onto my computer/server from within a servlet. I have a String called "url", from thereon here is my code: url = Streams.asString(stream); //gets the URL from a form on a webpage System.out.println("This is the URL: "+url); URI fileUri = new URI(url); File fileFromUri = new File(fileUri); onlyFile = fileFromUri.getName(); URL fileUrl = new URL(url); InputStream imageStream = fileUrl.openStream(); String fileLoc2 = getServletContext().getRealPath("pics/

file: URIs and Slashes

一个人想着一个人 提交于 2019-11-28 08:25:16
An application I'm working on involves accessing files on network file shares, and we're using URIs to specify the files' locations. My understanding of the file: URI is that they should take the form of file:// + path . In the case of a Windows network share, this path looks something like \\servername\dir\file , so the resultant URI becomes file:////servername/dir/file . This seems to be working great for Java's URI class , but the Win32 API seems to want a file://servername/dir/file style URI, which Java rejects because it "has an authority component". Am I understanding network-share URIs