# InterApp Open Local File

**URL:** <https://forums.fusetools.com/t/interapp-open-local-file/1921>\
**Category:** How-to Discussions\
**Created:** [October 17, 2016, 3:18pm UTC](https://forums.fusetools.com/t/interapp-open-local-file/1921 "2016-10-17T15:18:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Oliver](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@Daniel\_Oliver](https://forums.fusetools.com/u/Daniel_Oliver)\
**Post date:** [October 17, 2016, 3:18pm UTC](https://forums.fusetools.com/t/interapp-open-local-file/1921/1 "2016-10-17T15:18:44Z")

</div>

As the title suggests I am trying to open a locally stored file – in this case a pdf. For my use case, it is required that I download the file first since it is a secured file from a web server that requires passing an authentication token in the header.

I am testing with a publicly available pdf.

```auto
var InterApp = require('FuseJS/InterApp');
var FileSystem = require("FuseJS/FileSystem");
function openPdfFromUrl(){
	var path = FileSystem.cacheDirectory + "/" + "2016-NYC-Triathlon-Course-Map.pdf";

	var oReq = new XMLHttpRequest();
	oReq.open("GET", "http://www.nyctri.com/wp-content/uploads/2016/06/2016-NYC-Triathlon-Course-Map.pdf", true);
	oReq.responseType = "arraybuffer";
	oReq.onload = function (oEvent){
		var arrayBuffer = oReq.response;
		FileSystem.writeBufferToFile(path, arrayBuffer)
	    .then(function() {
	        console.log("Successful write");
	        openPdf(path);
	    }, function(error) {
	        console.log("Error while writing: " + error);
	    });
	}
	oReq.send(null);
	// InterApp.launchUri("http://www.nyctri.com/wp-content/uploads/2016/06/2016-NYC-Triathlon-Course-Map.pdf");
}

function openPdf(path){
	console.log("file:/" + path);
	InterApp.launchUri("file:/"+path);
}

```

It successfully writes the file but has trouble trying to open it on Android. I have not tested on iOS. The file is written to the file system correctly and can be opened outside of the app. I have tried with “file://”+path and have gotten a different error. The path as it is now resolves to: “file://storage/emulated/0/Android/data/com.apps.openingfiles/cache/2016-NYC-Triathlon-Course-Map.pdf”. Is this a limitation of InterApp and will I need to figure something out in Uno? Thanks!

---

<div class="post-metadata">

**Author:** ![BeeWarloc](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/beewarloc/32/186_2.png) [@BeeWarloc](https://forums.fusetools.com/u/BeeWarloc)\
**Post date:** [October 18, 2016, 11:49am UTC](https://forums.fusetools.com/t/interapp-open-local-file/1921/2 "2016-10-18T11:49:08Z")

</div>

Hi there 🙂

While testing your example I found a couple of issues:

The first problem is that a launched app does not have access to the path returned by `FileSystem.cacheDirectory`. Instead you need to use `FileSystem.androidPaths.externalCache`, which can be read by the launced app.

Also, instead of `"file:/" + path` you need to do `"file://" + path`, to create a valid (absolute) file uri.

Unfortunately it appears that `file:///` URIs currently do not work, due to a bug in our URI parser. I’ll create a ticket for this bug, there’s a fix in the works that’ll make it into a future release.

---

<div class="post-metadata">

**Author:** ![Daniel\_Oliver](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@Daniel\_Oliver](https://forums.fusetools.com/u/Daniel_Oliver)\
**Post date:** [October 18, 2016, 3:12pm UTC](https://forums.fusetools.com/t/interapp-open-local-file/1921/3 "2016-10-18T15:12:05Z")

</div>

Thank you for the reply and I will be awaiting the fix to the URI parser in a future release.
