cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ruben Vanhoeyveld (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-1966) [Feature req.] How to open local files on Android filesystem?
Date Wed, 05 Dec 2012 22:31:58 GMT

    [ https://issues.apache.org/jira/browse/CB-1966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13510854#comment-13510854
] 

Ruben Vanhoeyveld commented on CB-1966:
---------------------------------------

[~anis]:

{code:javascript}
function downloadFile(fileUrl, fileName) { // fileName = someFile.pdf or so
	fileName = fileName.replace(/ /g, '_');
	var remoteFile = encodeURI(fileUrl);
	var localFileName = fileName;//remoteFile.substring(remoteFile.lastIndexOf('/')+1);
	
	window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
		fileSystem.root.getFile(localFileName, {create: true, exclusive: false}, function(fileEntry)
{
			var localPath = fileEntry.fullPath;
			if (device.platform === "Android" && localPath.indexOf("file://") === 0) {
				localPath = localPath.substring(7);
			}
			var ft = new FileTransfer();
			ft.download(remoteFile,
				localPath, function(entry) {
					$('#downloadFileResult').html('Downloaded <a href="file:///sdcard/'+fileName+'">file:///sdcard/'+fileName+'</a>>');
				}, fail);
		}, fail);
	}, fail);
}
{code}
                
> [Feature req.] How to open local files on Android filesystem?
> -------------------------------------------------------------
>
>                 Key: CB-1966
>                 URL: https://issues.apache.org/jira/browse/CB-1966
>             Project: Apache Cordova
>          Issue Type: New Feature
>          Components: Android, CordovaJS
>    Affects Versions: 2.1.0
>         Environment: Android
>            Reporter: Ruben Vanhoeyveld
>            Assignee: Joe Bowser
>            Priority: Blocker
>              Labels: android, file, local, system
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I'm looking for functionality to open local files on the Android file system.
> The case for me is that when I download a file, it's stored in /mnt/sdcard/file.ext.
But I can't link to the file with file:/// or content://
> file:/// Gives me a blank white window with the text "undefined".
> content:// Does nothing.
> How can I implement some script to open files I just downloaded to the filesystem? (like
pdf/doc/...)
> Edit:
> [~macdonst]: This is a feature request!

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message