Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Rishabh_Jain
Posts: 111
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Hi All,

 

I am trying to download ppt file from server.And as soon as it gets downloaded showing the same in Adobe Reader.Following is the code for same:

 

function download() {
            try {
                blackberry.io.filetransfer.download(
                    "http://www.saronicferries.gr/content/pdfFiles/sample.pdf",
                     "/accounts/1000/shared/camera/sample.pdf",
                    function (result) {
                        alert("Download successful"+result.fullPath);
                        console.log("fullPath: " + result.fullPath);
						open();
                    },
                    function (result) {
                        alert("Download failed");
                        console.log("Error code: " + result.code);
                        console.log("HTTP status: " + result.http_status);
                        console.log("Source: " + result.source);
                        console.log("Target: " + result.target);
                    });
            }
            catch(e) {
                alert("Exception in download: " + e);
            }
        }

        function open() {
            try {
			blackberry.invoke.invoke({
					target: "com.rim.bb.app.adobeReader",
					action: "bb.action.OPEN",
					type: "application/pdf",
					uri: "file:////accounts/1000/shared/camera/sample.pdf"
}, function () { console.log("invocation success"); }, function (e) { alert("invocation failed: " + e); } );
               /* blackberry.invoke.invoke({
				    target: "sys.wordtogo.previewer",
                    action: "bb.action.VIEW",
                  
                    uri: "file:///accounts/1000/shared/camera/Test.docx"
                }, function () { console.log("invocation success"); }, function (e) { alert("invocation failed: " + e); } );*/
				
            }
            catch(e) {
                alert("Exception in open: " + e);
            }
        }

 Above code is working fine.

I am facing problem while downloading pdf file from dropbox link.Following is the code for same.Everthing is same except for URL.As it is having HTTPS while above link is only HTTP.

 

 


function download() { try { blackberry.io.filetransfer.download( "https://www.dropbox.com/s/ylfvkm4ahgcy6sj/sample.pdf", "/accounts/1000/shared/camera/sample.pdf", function (result) { alert("Download successful"+result.fullPath); console.log("fullPath: " + result.fullPath); open(); }, function (result) { alert("Download failed"); console.log("Error code: " + result.code); console.log("HTTP status: " + result.http_status); console.log("Source: " + result.source); console.log("Target: " + result.target); }); } catch(e) { alert("Exception in download: " + e); } } function open() { try { blackberry.invoke.invoke({ target: "com.rim.bb.app.adobeReader", action: "bb.action.OPEN", type: "application/pdf", uri: "file:////accounts/1000/shared/camera/sample.pdf" }, function () { console.log("invocation success"); }, function (e) { alert("invocation failed: " + e); } ); /* blackberry.invoke.invoke({ target: "sys.wordtogo.previewer", action: "bb.action.VIEW", uri: "file:///accounts/1000/shared/camera/Test.docx" }, function () { console.log("invocation success"); }, function (e) { alert("invocation failed: " + e); } );*/ } catch(e) { alert("Exception in open: " + e); } }

 

Please help me out.

Thanks in advance.

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

HI there,

Is the error callback being called? If so, can you share the results of it?

Have you white-listed the HTTPS URL in your config.xml?

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Rishabh_Jain
Posts: 111
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Thanks for your prompt response.

Below are the contents of config xml file(I have tried differnt combination of subdomains by making it as True as well false):

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-2012 Research In Motion Limited.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
        version="1.0.0.1"
        id="FileTransferDemo">
    <name>File Transfer Demo</name>
    <content src="local:///index.html"/>
    <author rim:copyright="2012"
            href="http://www.rim.com/"
            email = "haahmad@rim.com">Hasan Ahmad</author>
    <description>This application demonstrates how to use the file transfer API.</description>
    <license href="http://www.apache.org/licenses/LICENSE-2.0"></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://www.dropbox.com" subdomains="false" />
	<access uri="https://www.dropbox.com" subdomains="false" />
	<access uri ="*"/>
    
    <rim:permissions>
        <rim:permit>access_shared</rim:permit>
    </rim:permissions>
    
</widget>

 Yes, I am getting sucess callback.File also getting saved in the target path.But it saves less size of file rather than actual sizeBelow is the sucesscallback screenshot:sucessCallBack.png

 

Same pdf file we have hosted on WAMP server i.e local server, it seems to be work fine.

Below is the screen shot for file opening error when downloded through HTTPS:

pdfOpenErr.png

 

 

I have tried many things but no luck so far.

Please help me to overcome this.

Please use plain text.
Developer
Rishabh_Jain
Posts: 111
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Please help me to resolve this issue.We need to deliver it on high priority.As, the same thing is working fine for other platform.

Below is the updated description for same:

We are facing the issue in downloading and opening the attachments (hosted on a web server) through BB10 app.

 

Application architecture: HTML/JS/CSS hosted on a HTTPS URL in a web server.

 

The BB10 app is packaged to invoke this URL and launch the pages in the app.

 

When we try to open the attachments in this architecture they are not opening however, if the same is hosted in HTTP URL, it is working fine.

 

Request your inputs or help to get this resolved as we are facing customer escalations on this.

 

Please let me know in case you need further inputs on this.

 

On client side, it is not working.However, i have posted the whole code on my WAMP server which seems to be working fine.Below is the content of config xml file:

<?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.1"
        id="SampleTest">
    <name>SampleTest</name>
    <content src="http://10.16.67.123/assets/index.html" /> 
    <author rim:copyright="2012"
            href="http://www.rim.com/"
            email = "haahmad@rim.com">Hasan Ahmad</author>
    <description>This application demonstrates how to use the file transfer API.</description>
    <license href="http://www.apache.org/licenses/LICENSE-2.0"></license>

	<access uri="http://10.16.67.123" subdomains="true">
		<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>
		<feature id="blackberry.app" required="true" version="1.0.0.0"></feature>
	</access>
	

   <access uri="file:///" subdomains="true"></access>
	<access uri="http://www.saronicferries.gr" subdomains="true" />
	<access uri ="*"/>
    
    <rim:permissions>
        <rim:permit>access_shared</rim:permit>
    </rim:permissions>
    
</widget>

 Same thing is not working at clinet end.That is only an HTTPS link.

Help.

Please use plain text.
Developer
Rishabh_Jain
Posts: 111
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Please help me in getting through this.

Thanks in advance.

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Unfortuantely I'm not sure off the top of my head. The code is working for HTTP, but for HTTPS a 0-byte file is being returned which in turn is invalid.

 

My gut here is that this doesn't have to do with the code or the project settings, but with the configuration of the web server.

 

Have you had a chance to connect Web Inspector? Once connected, there is a Network panel that shows the request and response for various web traffic requests. The purpose would be to check the file request to see whether there is any error being thrown, or whether the request is being denied by the server, and ideally some information as to why.

 

If the request is being acknowledged and full file sent back, then we'd be looking at logging a bug report since, as you stated, it is working over HTTP and if the server is configured properly then there isn't a particular reason it shouldn't work over HTTPS.

 

 

That being said, you must white-list the HTTPS URL. I see that you did at one point, but your latest config.xml only has a whitelist for the HTTP version of the URL and not the HTTPS URL. That will most certainly cause problems (even if it is not the cause now, it will cause issues later.) If you are connecting to an external URL to download files via HTTPS, you will need something like this:

 

<access uri="https://saronicferries.gr" subdomains="true" />

 

Note that you do not need the www to be present, the subdomains="true" will satisfy that piece.

 

Again, you did the white-listing before and it wasn't rhe solution, so I don't expect this to solve this current issue, which is why we need to connect Web Inspector and see what is happening in the Network panel. That being said, without white-listing the HTTPS URL, we will see issues down the line.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Rishabh_Jain
Posts: 111
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Thanks for your quick response.

While making bar file, i am enabling web inspector.So, while running application it showing web inspector dialog.Now device is connected to System.On chrome browser, typing the same ip address followed by port number.It's showing the logs at my end.

But the issue is coming at my clend location.While he is following the same steps.On chrome it showing blank screen only.No web Logs.Is there any other way, of checking out the logs.

 

Below is the device configuartion details of Devicedevice_network.png

 

Also, when i try to installl app through BB Playbook manager connected device through USB, it not retriving list of apps installed.But when i saved ip address, it gets connected nd got apps list retrived.

Show not able to fetch logs at clent side.Is there any otherv way of fetching logs out.

Please help me out.It''s very urgent.

 

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Has the client-end put their device into Developer Mode?

Also, are you sharing the same debug BAR file with the client-end or are they installing through some other process (i.e. BlackBerry World?)

In general, if no other applications are open, the IP for web inspector will either be the WiFi IP or the USB IP (169.254.0.1)

The port begins at 1337, and for each debug application open, it increases by one (i.e. 1338, 1339, etc.)

The client-end could try connecting their device to their PC via USB and ensure that Development Mode is enabled, then run the application and open Chrome/navigate to the USB IP. If port 1337 doesn't work, try 1338 and 1339. If it still doesn't work, there is likely another issue (unless more than 3 debug applications are simultaneously running.)

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Rishabh_Jain
Posts: 111
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Please help in getting resolve this.

Please use plain text.
Developer
Rishabh_Jain
Posts: 111
Registered: ‎07-11-2011
My Device: 8900
My Carrier: Airtel

Re: Pdf File is not getting downloaded with HTTPS url in bb10 webworks: filetransfer.download

Thanks for quick response.

Seems like it is the problem related to following error:

 

The page at https://dl.dropboxusercontent.com/assets/html/sample_attachments.html ran insecure content from local:///chrome/webworks.js.
The page at https://dl.dropboxusercontent.com/assets/html/sample_attachments.html displayed insecure content from http://localhost:8472/extensions/get/?hash=75e5fd7c4b2ada1a71469c74ecd4bf9d&version=1.0.4.11.

 

Above error ima getting in below thread discussion:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Issue-opening-files-in-web-Link-...

 

I think if above probelm get resoved, it will also work.

 

Waiting something fruitful to come out.

Please use plain text.