Permalink
Browse files

Merge pull request #2 from webworks/next-fileDemo

Next file demo
  • Loading branch information...
2 parents b3d1c2c + 91aa699 commit b63a23157e5477be8bbea4dd11c8686a3c19e08b @haahmad haahmad committed Jul 13, 2012
View
No changes.
View
@@ -0,0 +1,26 @@
+<?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" />
+ <access uri="http://bojap.com/" subdomains="true" />
+ <access uri="http://rim.com/" subdomains="true" />
+
+ <rim:permissions>
+ <rim:permit>access_shared</rim:permit>
+ </rim:permissions>
+
+</widget>
Binary file not shown.
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<head>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <script src="local:///webworks-1.0.0.7.js"></script>
+ <link rel="stylesheet" href="jquery/jquery.mobile-1.1.0.min.css" />
+ <script src="jquery/jquery-1.7.1.min.js"></script>
+ <script src="jquery/jquery.mobile-1.1.0.min.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>
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<head>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <script src="local:///webworks-1.0.0.7.js"></script>
+ <link rel="stylesheet" href="jquery/jquery.mobile-1.1.0.min.css" />
+ <script src="jquery/jquery-1.7.1.min.js"></script>
+ <script src="jquery/jquery.mobile-1.1.0.min.js"></script>
+ <script>
+ function ready() {
+ document.getElementById("upload").onclick = upload;
+ document.getElementById("open").onclick = open;
+ }
+
+ function upload() {
+ try {
+ blackberry.io.filetransfer.upload(
+ blackberry.io.sharedFolder + "/documents/Getting Started with Adobe Reader.pdf",
+ "http://bojap.com/omg/uploader.php", //Use address of server handling file upload [10.137.251.209:443/upload]
+ function (result) {
+ alert("Upload successful");
+ alert("Bytes sent: " + result.bytesSent);
+ alert("Response code: " + result.responseCode);
+ alert("Response: " + result.response);
+ },
+ function (result) {
+ alert("Upload failure");
+ alert("Error code: " + result.code);
+ alert("Source: " + result.source);
+ alert("Target: " + result.target);
+ alert("HTTP Status: " + result.http_status);
+ }
+ ,
+ {
+ fileKey : "file",
+ fileName : "Getting Started with Adobe Reader.pdf",
+ mimeType : "application/pdf",
+ chunkedMode : "true",
+ chunkedSize : 1024
+ }
+ );
+ }
+ catch(e) {
+ alert("Exception in upload: " + e);
+ }
+ }
+
+ function open() {
+ try {
+ blackberry.invoke.invoke({
+ target: "sys.browser",
+ uri: "http://bojap.com/omg/upload/"
+ }, 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="upload">Upload File</button><br />
+ <button id="open">View File</button>
+</body>
Binary file not shown.
View
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<head>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <link rel="stylesheet" href="jquery/jquery.mobile-1.1.0.min.css" />
+ <script src="jquery/jquery-1.7.1.min.js"></script>
+ <script src="jquery/jquery.mobile-1.1.0.min.js"></script>
+
+ <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";
+ }
+ </script>
+</head>
+<body>
+ <h1 data-role="header">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 and FileSystem API</button><br />
+</body>

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit b63a231

Please sign in to comment.