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
New Developer
Posts: 27
Registered: ‎07-20-2009
My Device: Not Specified

WebWorks Extension: How to read binary file located in the embedded HTML5 app

I am writing a custom WebWorks extension that requires a binary file that is to be staged within the embedded web application. What I would like to do is to pass in the relative location of the binary file via my extension's JavaScript interface. From there, I would like to have the extension use a FileConnection to read the raw bytes of the binary file and do some fun stuff. e.g.

 

FileConnection fconn = (FileConnection)Connector.open(webAppLocation + relativeLocation);

 

However, I am unable to find in documentation what is the base URL to where the embedded web application is deployed. Can someone help me by providing the secret sauce?

 

Thanks,

Scott

New Developer
Posts: 27
Registered: ‎07-20-2009
My Device: Not Specified

Re: WebWorks Extension: How to read binary file located in the embedded HTML5 app

I still have not found anything in the WebWorks documentation regarding this, but I found a nugget in a forum post that I'm going to try...

 

local:///

 

The post:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Hi-going-back-to-local-html-inst...

Retired
Posts: 856
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: WebWorks Extension: How to read binary file located in the embedded HTML5 app

Tim Neil's stuff is solid gold of course.

 

Another hint is to compile with the -s option which will create a full dump of everything that's going into the BAR/COD file. Then you can see the exact path to where things are in your app.

Tim Windsor
Open Source Technical Lead
New Developer
Posts: 27
Registered: ‎07-20-2009
My Device: Not Specified

Re: WebWorks Extension: How to read binary file located in the embedded HTML5 app

No luck with compiling with the -s (or -v) options. The output does not reference the HTML/CSS/JS or image resources in the ZIP file.

 

What URL does WebWorks use to load my start page...index.html in the root of my zip file? If I want to make a Connection to that file, what do I use as the URL in my Connector.open() statement?

 

Which type of connection will this create? FileConnection, HTTPConnection, ContentConnection, something else?

 

Specifically, I'm trying to access a file called /resources/logo.png from the root of my zip.

 

This seems like it should be easy to do on the surface.

 

Thanks,

Scott

Retired
Posts: 856
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: WebWorks Extension: How to read binary file located in the embedded HTML5 app

I haven't tested it, but that "local:///" url may only work within the HTML and Javascript.

 

Also, FileConnections will only let you access the actual file system, not the resources within the COD file. You'll need to use the Class.getResourceAsStream() method, which returns an InputStream.

 

However, if you access a file through your HTML, you should be able to reference it by something like "/extension/test/img/logo.png".

Tim Windsor
Open Source Technical Lead