Skip to content

Commit

Permalink
Initial commit for file transfer, file download case works
Browse files Browse the repository at this point in the history
  • Loading branch information
haahmad committed Jul 10, 2012
1 parent 29eb48c commit 6feb491
Show file tree
Hide file tree
Showing 8 changed files with 1,495 additions and 0 deletions.
Empty file added fileTransfer/README
Empty file.
24 changes: 24 additions & 0 deletions fileTransfer/config.xml
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns=" http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0"
id="FileTransferDemo">
<name>File Transfer Demo</name>
<content src="local:///index.html"/>
<author rim:copyright="No Copyright"
href="http://www.rim.com/"
email = "author@rim.com">Research In Motion Ltd.</author>
<description>This application demonstrates how to use the file transfer API.</description>
<license href="http://www.apache.org/licenses/LICENSE-2.0">My License</license>

<feature id="blackberry.io" required="true" version="1.0.0.0"></feature>
<feature id="blackberry.io.filetransfer" required="true" version="1.0.0.0"></feature>
<feature id="blackberry.invoke" required="true" version="1.0.0.0"></feature>

<access uri="http://w3.org/" subdomains="true" />

<rim:permissions>
<rim:permit>access_shared</rim:permit>
</rim:permissions>

</widget>
Binary file added fileTransfer/device/filetransfer.bar
Binary file not shown.
56 changes: 56 additions & 0 deletions fileTransfer/fileDownload.html
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="local:///webworks-1.0.0.7.js"></script>
<script>
function ready() {
document.getElementById("download").onclick = download;
document.getElementById("open").onclick = open;
}

function download() {
try {
blackberry.io.filetransfer.download(
"http://www.w3.org/2011/Talks/0928-webtv-nem-fd/slides.pdf",
blackberry.io.sharedFolder + "/downloads/W3html5TV.pdf",
function (result) {
alert("Download successful");
alert("fullPath: " + result.fullPath);
},
function (result) {
alert("Download failed");
alert("Error code: " + result.code);
alert("HTTP status: " + result.http_status);
alert("Source: " + result.source);
alert("Target: " + result.target);
});
}
catch(e) {
alert("Exception in download: " + e);
}
}

function open() {
try {
blackberry.invoke.invoke({
target: "com.adobe.AdobeReader",
action: "bb.action.OPEN",
type: "application/pdf",
uri: "file://" + blackberry.io.sharedFolder + "/downloads/W3html5TV.pdf"
}, function () { console.log("invocation success"); }, function (e) { alert("invocation failed: " + e); } );
}
catch(e) {
alert("Exception in open: " + e);
}
}

window.addEventListener("load", function () {
document.addEventListener("webworksready", ready);
}, false);
</script>
</head>
<body>
<button onclick="history.back()">Back</button><br />
<button id="download">Download File</button><br />
<button id="open">Read File</button>
</body>
Binary file added fileTransfer/filetransfer.zip
Binary file not shown.
28 changes: 28 additions & 0 deletions fileTransfer/index.html
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script>
function downloadFile() {
document.location.href = "local:///fileDownload.html";
}

function uploadFile() {
//document.location.href = "local:///fileUpload.html";
}

function xhrFile() {
//document.location.href = "local:///xhr2.html";
}

function fsAPITest() {
//document.location.href = "local:///fileSystem.html";
}
</script>
</head>
<body>
<h1>File Transfer</h1>
<button id="downfile" onclick="downloadFile()">Download File</button><br />
<button id="upfile" onclick="uploadFile()">Upload File</button><br />
<button id="xhr2" onclick="xhrFile()">HTML5 XHR Level 2</button><br />
<button id="fsapi" onclick="fsAPITest()">HTML5 FileSystem API</button>
</body>
Binary file added fileTransfer/simulator/filetransfer.bar
Binary file not shown.

0 comments on commit 6feb491

Please sign in to comment.