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

Native Development

Reply
Developer
Posts: 16,647
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Open a file from data folder via invocation

I have an attachment file (ppt) that is saved in the data folder.

I want to open the file using an invocation:

InvokeActionItem::create(InvokeQuery::create().invokeActionId("bb.action.OPEN").
mimeType(mimeType).uri(fileURI).fileTransferMode(FileTransferMode::CopyReadWrite)));

with these values set:

mimeType:  application/vnd.ms-powerpoint

fileURI:        file:///accounts/1000/appdata/app-id/data/Attachments/sample1.PPTX

 

As a result i get a dialog asking me about the app to invoke it with, i choose DocsToGo and get:

"This file cannot be opened (generalErrInvalidParameter)"

 

Do i have to copy the file into the shared folder to be able to invoke it? As i have all kind of documents i don't want to specify a target ID.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Open a file from data folder via invocation

I don't think the invoked app gets any special ability to penetrate your app's sandbox protection, so data in ./data will not be readable this way.

There is a sharewith/ folder that leads to a set of folders under /accounts/1000/sharewith, intended for sharing via invocation (as far as I can tell) but they seem to be restricted to access from a subset of the apps on the system (specifically those which have group membership of pim, dlna, bluetooth, media, and search). I haven't investigated whether writing a file there will allow it to be read by another app like DocsToGo.. it's possible.

I think for now copying to /var/tmp or /tmp may be the main alternatives unless you want to do it through shared/documents or the like. (I don't think I've seen any documentation on the use of either of those temp folders, mind you.)

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 16,647
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Open a file from data folder via invocation

I thought along the lines of the file being shared by the invocation due to file transfer mode, the API says it copies the file to the sandbox of the target app
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Open a file from data folder via invocation

Oops, I wasn't familiar with those options yet.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 16,647
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Open a file from data folder via invocation


peter9477 wrote:
Oops, I wasn't familiar with those options yet.

Not that there is really any need to be if they don't work :Yawn:

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Open a file from data folder via invocation

Simon, even if this copying worked, and DocsToGo could open the file, how would it ever get deleted from the user's device after they closed it?

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 16,647
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Open a file from data folder via invocation

No clue, maybe the invocation framework is supposed to delete the copied file after the invocation is finished.

Well, i guess i'll grab Shadid in Hong Kong (if he is there) and ask him about it :smileyhappy:
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 16,647
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Open a file from data folder via invocation

I did not remember to ask anybody at bb jam asia about this, so i spent some time with the issue today.

i have 5 different attachments:
-pptx
-txt
-pdf
-docx
-xls

all work with the invocation i use, except for the pptx, which i find really strange.
i am hesitant to rewriting my attachment handling only due to this case.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: Open a file from data folder via invocation

Developer
Posts: 16,647
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Open a file from data folder via invocation


bmorr wrote:

Maybe using the filepicker would suffice for your users?

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__pickers__filepicker.html


I don't see how that applies here. My application downloads the attachments and displays an icon to represent them. When clicking on the icon the attachment should be opened in the matching application.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter