Comments (54)
HI @pwlin ,I am colin,glad to use your new plugin2
I am using PGB 3.3 with your sample code
https://github.com/pwlin/cordova-plugin-file-opener2/blob/master/README.md
let me feedback some issues for you
My divice
Android 4.0.3、Android 4.1.1、iOS 7.0.6
Q1
when the file path is not correct (such like "'/sdcard/Download/starwars312313.pdf'")
in Android,it will not trigger the "error" method,so the alert window can't appear
in iOS,it will crash the app (immediately crash),so the alert window can't appear too
Q2
could you give me a iOS sample "File Path",So I can made a test for this
like that ?
/var/mobile/....
from cordova-plugin-file-opener2.
@bau720123 Hi Colin, thanks for testing this out, sorry I have been pretty busy at work lately but I will look into this as soon as possible and will reply again.
from cordova-plugin-file-opener2.
thanks @pwlin
Please take care of yourself
from cordova-plugin-file-opener2.
Hi,
First thanks for this plugin !
I'm testing it right now on iOS7 and it crashes the application.
Maybe the file path is not correct (but it should not crash anyway).
Investigating...
from cordova-plugin-file-opener2.
After investigations the path was incorrect, causing the application to crash brutally...
If the path is good then it works!
I would be great IMO to have an option to open the file with the default registered application, without prompting the user for the one to use (in my case I'm using it to open a PDF, and I'd like to be able to open it directly with the default viewer).
from cordova-plugin-file-opener2.
nice investigations (I found this situation too)
thanks @DjulLau
let us waitting for new version
from cordova-plugin-file-opener2.
hi @pwlin
it;s about two months ago...
well~is there any update information?
from cordova-plugin-file-opener2.
hi @pwlin
another 17 days ago...
is the plugin have a upgrade version Recently ?.
from cordova-plugin-file-opener2.
hi @bau720123
As I couldn't wait for my project I made some changes for my needs :
- Added parameters for choosing opening mode (Preview, openInMenu, optionsMenu) and for animate on opening (true/false)
- Better error handling so it doesn't crash when the file doesn't exists
I can send you the files if you want.
from cordova-plugin-file-opener2.
hi @DjulLau
very thanks of you
my email is
[email protected]
from cordova-plugin-file-opener2.
Hello guys, let me I ask you.
since i'm also interested and i'm not good with java, why don't you create
a fork of this project with your changes?
Regards
Rocco R.
Send from my mobile. Please excuse typos.
On 15 May 2014 12:35, "bau720123" [email protected] wrote:
hi @DjulLau https://github.com/DjulLau
very thanks of you
my email is
[email protected]—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-43194359
.
from cordova-plugin-file-opener2.
Hi @xdemocle
Sorry but I've done my mods only for iOS and don't know when I'll have the time to do it on Android.
from cordova-plugin-file-opener2.
@DjulLau , do you have your fixes somewhere so we can merge it with this plugin?
from cordova-plugin-file-opener2.
@bau720123, my apology for late reply. I just tested the plugin with latest version of Cordova (3.5.*) and on Android side everything works. As for iOS, I don't have an iphone at the moment to test. It would be good if the fixes @DjulLau implemented can be merged in my plugin.
from cordova-plugin-file-opener2.
hi @pwlin
@DjulLau have been send me a fix file to me
could you give me your email
so I can email to you
from cordova-plugin-file-opener2.
hi @pwlin
I have been send a email to
[email protected]
hope can help you~
from cordova-plugin-file-opener2.
@bau720123 Thanks, I have received it.
As DjulLau himself says:
After investigations the path was incorrect,
causing the application to crash brutally...
If the path is good then it works!.
The plugin is actually fine it seems.
So all you have to do it to make sure the file exists before trying to open it with this plugin. (maybe use File
plugin first to see if the file exists?)
As for his additional functionality, they are not very important and there is no Android equivalent for them. So for the moment I won't commit them otherwise there will be a huge difference between iOS and Android versions.
I have already committed the change in other thread, so let's see when Phonegap approve the 1.0.6
release so you can test that.
Can you get this plugin to work properly in Android with the given example in my Readme file?
from cordova-plugin-file-opener2.
Hi guys ! Sorry for the late reply you weekend workers ;-)
My version contains :
- Error checking (path parsing, and try catch for opening). IMHO the plugin should not crash if the path is incorrect or the file doesn't exist.
- One new parameters for specifying mode to open the file.
- One new parameters for specifying if animation should happen.
I would not say the mode parameter is not very important on iOS because if you try to open a PDF with the original plugin (using presentOptionsMenu) with a stock iPhone for example it will prompt you to open the file with Safari and other apps but not with the default iOS preview app which is to me the most useful in that case.With "preview" mode your app is able to open a PDF seemlessly so I think it's a must have.
As @pwlin said I wasn't sure about Android equivalent so I didn't fork with the new interface...
from cordova-plugin-file-opener2.
@DjulLau Thanks for your feedback. I agree that the plugin should check if the file/path exists before trying to open it. I will implement that in an upcoming version pretty soon.
The problem with "mode" parameter is that there is no equivalent in Android as far as I can understand. Android will always present you with a list of possible apps you can open the file with. I will see what I can do to implement "mode" parameter in both iOS and Android.
from cordova-plugin-file-opener2.
By the way, there is now a new version of this plugin (version 1.0.7) available at PhoneGap Build page (https://build.phonegap.com/plugins/801). It still doesn't have the check for the existence of path/file, but apart from that, everything else should work perfectly. Please test!
from cordova-plugin-file-opener2.
hi @pwlin
it seem still have some trouble in 1.0.7
these are your code
<script>
cordova.plugins.fileOpener2.open(
'/sdcard/Download/starwars.pdf',
'application/pdf',
{
error : function(errorObj) {
alert('Error status: ' + errorObj.status + ' - Error message: ' + errorObj.message);
},
success : function () {
alert('file opened successfully');
}
}
);
</script>
suppose the '/sdcard/Download/starwars.pdf' address in android is right,of course in iOS is wrong
when in Android,it will trigger nothing,just nothing,no any message response
when in iOS,it will trigger success,but the address of course wrong,another strange way,it will show the AirDrop window
http://www.littlebau.com/strange2.png
from cordova-plugin-file-opener2.
hi @pwlin
Using this plugin how can I open the PDF from within my application in Android?
I have tried multiple options like:
file:///android_asset/www/content/resources/1.pdf
and
/www/content/resources/1.pdf
But no success!
from cordova-plugin-file-opener2.
hi @pwlin
anything update ?
from cordova-plugin-file-opener2.
I have not yet had success with this on Android. I have tries many different time for the file path as did @yogesh061 above
file:///android_asset/www/content/resources/1.pdf,
/www/content/resources/1.pdf
/storage/sdcard1/Downloads/1.pdf etc etc.
When I download - I get no error but nothing happens. I am using phonegap build so debugging is limited. Am I missing something do I need to include a js file for this to work?
David
from cordova-plugin-file-opener2.
On IOS, exporting a pdf works for 3rd party applications like adobe reader. However, recently, the ios mail client does not attach the pdf. It will just compose an email with the file name in the subject line.
from cordova-plugin-file-opener2.
I have it working now. Firstly it is not possible (I don't think) to access the content of the apk androif package file in this way. so file:///android_asset/www/content/resources/1.pdf will not work.
On my phone I must put file:// in front of the path name or nothing happens when I call so this is the only thing that works for me:
file:///storage/sdcard1/Downloads/1.pdf
from cordova-plugin-file-opener2.
hi @davidcotter
thanks for your feedback
when in Android
I use "/sdcard/download/sample.pdf" have no response
but if I use "file:///storage/sdcard/downloads/sample.pdf",it will trigger the error message,
"File not found"
from cordova-plugin-file-opener2.
hi @pwlin
it seem still have some trouble in "1.0.8" in PGB
these are your code
<script>
cordova.plugins.fileOpener2.open(
'/sdcard/Download/starwars.pdf',
'application/pdf',
{
error : function(errorObj) {
alert('Error status: ' + errorObj.status + ' - Error message: ' + errorObj.message);
},
success : function () {
alert('file opened successfully');
}
}
);
</script>
Android is complete no problem
but in iOS,it will always trigger success,but the address of course wrong,another strange way,it will show the AirDrop window
http://www.littlebau.com/strange2.png
from cordova-plugin-file-opener2.
I'm trying to open a PDF file in iOS, but I'm not sure if the file path is correct. Could somebody paste a working example in iOS here?
from cordova-plugin-file-opener2.
Hi,
here is a working path for ios : file:///var/mobile/Applications/11111111-1111-1111-111111111111/Documents/file.pdf
where 1111-111...111 is the applciation id
I found an issue, The pdf opening works very well with adobe, and imessage i think (i haven't test it, but the file appears). But with Mail app it doesn't work, the file is not well interpreted. the file name is in the object message but it is everything.
from cordova-plugin-file-opener2.
hi @guillaumebo
thanks for your solve way
but how to find a "applciation id" in "phonegao code"
because of that I think different ios true device have different "applciation id"
from cordova-plugin-file-opener2.
@bau720123 maybe look at the cordova-plugin-file from apache ? it may help ?
i am using cordova-plugin-file-transfer from apache too, so i have direct the file link
from cordova-plugin-file-opener2.
oh...
thanks @guillaumebo
I will try for this
thanks for your help
from cordova-plugin-file-opener2.
Hi Guys, how are you doing @bau720123
You have no idea how sorry i am for neglecting supporting you. Please accept my deep and sincere apology. I have been very busy with my day job and family stuff and all that jazz.
As you already realized, this plugin works more and less as it should with Android. You give it a correct path and a correct mime type and off it goes.
In iOS, as @guillaumebo mentioned, you need to get a "file entry point" from Cordova's standard File plugin which is nothing more than a wrapper around the HTML5 standard File System API.
After you got the file point entry, pass it to this plugin. It's pretty simple actually.
Unfortunately I have no iphone at this moment to test it with iOS but I am sure it will work if you have Adobe PDF reader installed on your phone and you get a correct file point entry.
from cordova-plugin-file-opener2.
hello @pwlin
fully understand what you meaning
really thnaks for your help recently
if could,Do not be so work hard, the most important is health family XD
from cordova-plugin-file-opener2.
@bau720123 Thanks for your concerns, I promise to take care :)
from cordova-plugin-file-opener2.
Goo day, thanks you for the great plugin!
I have a problem: with iOS8 everything works perfect, but with android I get: Unable to find item.
I tried with 2 urls: "file:/// and cdvfile://"
If I try to open my link in inappbrowser - everything is ok.
when I try to open with cordova.plugins.fileOpener2.open... it's goes to success callback.
(if i type wrong file name it's goes to error callback)
after that I get message: "Unable to find item" (native message at bottom).
file saved to device by org.apache.cordova.file-transfer: fileSystem.root.toURL() + filename.
Device: Samsung S3 / android 4.3
Thanks you!
####################### Solved
So on iOS device we can download file with plugin "org.apache.cordova.file-transfer" to fileSystem.root.toURL() and then read from it.
On adnroid device we can download to fileSystem.root.toURL(), open it by link in inappbrowser, but not with fileOpener2 (we don't have access to /data/data/******/files/files ? )
How to solve: On android devices we are able to download file into /storage/emulated/0/ (for example) and use fileOpener2.
from cordova-plugin-file-opener2.
Hello,
I just installed your plugin and everything is ok. Everything? Well I would like to open a PDF which is generated dynamically on my server. If I passed the information as http://... it says that the file is not found.
1/ Is it possible to do so without having to download the pdf first?
2/ What is the correct syntax I have to use?
Thanks for your help.
Chris
from cordova-plugin-file-opener2.
@1stposition-il glad you have found a solution to your problem, maybe you can give a complete example for other people to use?
@ctricaud You must first save the PDF in the local file system with Cordova/HTML5 file system API then open it with this plugin. It can not open files directly from remote HTTP servers.
from cordova-plugin-file-opener2.
Thanks, yes this is what I have done.
The small issue is that it takes some place on the download directory for nothing.
from cordova-plugin-file-opener2.
@pwlin, ok!
I created two gists with services to manage this stuff.
And fileSrvc is not tested (in my app everything was little different)
- fileSrvc to download files for cordova-plugin-file-opener2
https://gist.github.com/Igor-lkm/94adfb2daed65ed6f18c
so, to download file to right path we need to:
fileSrvc.download('http://someurl.com/hi.pdf', function(err, nativeURL){
/* open file here.. we get nativeURL to open*/
});
"Magic" is here:
if (iosDevice !== null) {
downloadPath = fileSystem.root.toURL() + fileInternal;
} else {
downloadPath = cordova.file.externalDataDirectory + fileInternal;
}
- fileOpenerSrvc for cordova-plugin-file-opener2
https://gist.github.com/Igor-lkm/1246ef5b87eba17645e2
This will open the file with right mime type by nativeURL:
fileSrvc.download('http://someurl.com/hi.pdf', function(err, nativeURL){
fileOpenerSrvc.open(
nativeURL,
successCallback,
errorCallback
);
});
if it's not working - I will create better example!
from cordova-plugin-file-opener2.
Hello @pwlin, I'm trying to setup a download and open feature with file-transfer and the opener2 on IOS and ANDROID devices.
On android it's working fine, but on the IOS, the downloaded file isn't opening. When clicking to open the file, a modal with available readers are displayed. I select a PDF reader, but nothing happens.
The file-opener fail callback is executed, but a undefined error is passed on the parameters.(Same occurs sometimes on android, but the file opens successfully)
var open = function(path, successCallback, errorCallback) {
var ext = getExt(path);
var type = getMimeByExt(ext);
successCallback = function(){
alert('success');
};
errorCallback = function(e){
alert('Error status: ' + e.status + ' - Error message: ' + e.message);
};
if(type === false) {
alert('error: unknown file type');
return;
}
try {
alert('open path:'+ path + ' type: '+ type);
cordova.plugins.fileOpener2.open(
path, // You can also use a Cordova-style file uri: cdvfile://localhost/persistent/Download/starwars.pdf
type,
{
error: successCallback,
success: errorCallback
}
);
} catch (e) {
alert('error: ' + JSON.stringify(e));
}
}
I using the great sample code of @Igor-likhomanov, the phonegap version is 3.6.3, and the plugin version is 1.0.11
The source is here: https://github.com/t4deu/file-opener-test
Please, can anyone help me on this?
from cordova-plugin-file-opener2.
Hello @t4deu ,
Could you please show what "alert('open path:'+ path + ' type: '+ type);" outputs on iOS?
I'm using Phonegap Build, so in config.xml I have:
<preference name="iosPersistentFileLocation" value="Library" />
and here:
cordova.plugins.fileOpener2.open(
path,
type,
{
error: successCallback,
success: errorCallback
}
);
error ===> successCallback
success ===> errorCallback
Should be so? :)
from cordova-plugin-file-opener2.
@Igor-likhomanov thank you very much for posting your examples, I am sure it will be useful to other users.
@t4deu I wish I could help you with iOS issues but unfortunately at the moment i don't own any iDevices to troubleshoot the stuff on. I hope @Igor-likhomanov or some other users here can help you. I will test the plugin as soon as I get my hands on an iphone again. My sincere apologies.
from cordova-plugin-file-opener2.
I am trying to open a file of which I know for sure it is on the file system. I just downloaded it there with the file-transfer plugin. I get the result and use toURL() to get the location. Howevery fileopener2 says it cannot find the file.
I also used this:
$window.resolveLocalFileSystemURL(directory, function (fileSystem) {
if (fileSystem.isFile === true) {
q.resolve(fileSystem);
} else {
q.reject({code: 13, message: "input is not a file"});
}
}
This resolves, which means the file is on the filesystem. After this I use toURL() on the result. But still fileopener2 says the file does not exist.
The toURL function return this:
file:///storage/emulated/0/Android/data/com.test.app/files/123456789/test/Offerte.pdf
from cordova-plugin-file-opener2.
@Langstra have you tried to hard code the file path in open
function to see if it works?
cordova.plugins.fileOpener2.open("/storage/emulated/0/Android/data/com.test.app/files/123456789/test/Offerte.pdf", "application/pdf", ...........)
from cordova-plugin-file-opener2.
What I had to do was this:
decodeURI(result.toURL().substr(7))
After I received the FileEntry from the filesystem. It seems that the file:/// is killing, as well as encoded spaces and other special characters.
from cordova-plugin-file-opener2.
@Langstra
Don't use decodeURI()
, use decodeURICompoment()
instead. It will automatically decode all special characters.
from cordova-plugin-file-opener2.
Hello,
I upload the PDF file with my app, as an asset in a "pdf" folder. It's there - when trying to open it directly via url the network shows a 200 OK for "file:///android_asset/www/pdf/mypdf.pdf"
But when trying with fileopener2 :
cordova.plugins.fileOpener2.open( 'pdf/mypdf.pdf'
It doesn't work. I tried a lot, like '../pdf/mypdf.pdf', '/pdf/mypdf.pdf', "file:///android_asset/www/pdf/mypdf.pdf", ...... Nothing.
Please help ?
Thanks !
( Android 5.1 - Nexus 5 )
from cordova-plugin-file-opener2.
The way I worked it out was by getting the file from the filesystem.
Getting the url of the file. Remove the first 7 characters and then open it
with fileOpener2.
$cordovaFileOpener2.open(
decodeURIComponent(result.toURL().substr(7)), extention).then(
function() {
$ionicLoading.hide();
},
function(e) {
console.log(fileURL);
console.log('Error status: ' + e.status + ' - Error message: ' +
e.message);
}
);
Met vriendelijke groet,
Wybren Kortstra
On 27 May 2015 at 11:38, JerryBels [email protected] wrote:
Hello,
I upload the PDF file with my app, as an asset in a "pdf" folder. It's
there - when trying to open it directly via url the network shows a 200 OK
for "file:///android_asset/www/pdf/mypdf.pdf"But when trying with fileopener2 :
cordova.plugins.fileOpener2.open( 'pdf/mypdf.pdf'
It doesn't work. I tried a lot, like '../pdf/mypdf.pdf', '/pdf/mypdf.pdf',
"file:///android_asset/www/pdf/mypdf.pdf", ...... Nothing.Please help ?
Thanks !
( Android 5.1 - Nexus 5 )
—
Reply to this email directly or view it on GitHub
#1 (comment)
.
from cordova-plugin-file-opener2.
Hello,
I am using your plugin and it works perfectly now for me on Android and on iOS.
I faced an issue that on iOS I only saw the "open with"-dialog, but when I clicked one nothing happened.
After some debugging I found out that the URL must not contain any whitespaces, otherwise it will not open.
I just wanted to mention this just in case someone faces the same problem.
from cordova-plugin-file-opener2.
Hello,
On Android, when I open a pdf file with fileOpener2 then I press on back button to go back on my application it reload the app and I lose my navigation stack. Is there a way to avoid it ?
thanks.
from cordova-plugin-file-opener2.
Hello,
Im also facing the problem with FileOpener2 plugin in Android,
I was trying cordova.plugins.fileOpener2.open() with the file path as /pdf/mypdf.pdf', '/pdf/mypdf.pdf', "file:///android_asset/www/pdf/mypdf.pdf', /sdcard/Download/pdf/mypdf.pdf'
Still showing the error: File not found.
Please advice how I could resolve this.
I need to fix this very urgent. Please help me on this.
Thanks
from cordova-plugin-file-opener2.
Not really an issue, but something that took me a while to figure out. Your example in the README.md uses cordova.fileOpener2.open({...})
but you have changed it to cordova.fileOpener2a.open({...})
. Because of that, I couldn't figure out why I couldn't open a file.
Maybe you could update your README.md? To prevent further confusions.
from cordova-plugin-file-opener2.
Related Issues (20)
- Migrating to Target 30(Android Q) , plugin is not working HOT 3
- Unable to open image file in android HOT 1
- FileOpener2 error in electron 11 HOT 1
- Plugin is not handling Cookies in React project HOT 1
- Add documentation for error codes
- USB PORT PARAM HOT 1
- doesnt work with IOS and assets-library
- Usage in Capacitor HOT 1
- pdf opened in an external app cannot save changes HOT 1
- Cannot open file while is at app data location '/data/data/<app_id>/cache' HOT 2
- unable to open application/pdf format in Android device (Samsung Galaxy S21 and Samsung Galaxy S21+) HOT 2
- android.support.v4.content.FileProvider not found HOT 7
- Relative URIs are not supported.
- remove: android.permission.REQUEST_INSTALL_PACKAGES from plugins.xml HOT 85
- Text Open file in always localized in english (Android) HOT 4
- There was a problem parsing the package for android install apk HOT 1
- Can't edit file HOT 2
- Getting error after updating plugin to 4.0.0 on Android Studio HOT 2
- Unable to open some MP4 files on iOS? HOT 1
- This plugin has a maintained forked repo now - please use and follow HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-file-opener2.