Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

openDocument not working on iOS #158

Closed
raminious opened this issue Oct 15, 2016 · 8 comments
Closed

openDocument not working on iOS #158

raminious opened this issue Oct 15, 2016 · 8 comments

Comments

@raminious
Copy link

raminious commented Oct 15, 2016

RNFetchBlob.ios.openDocument: Not worked without throwing any error. it only return null result on success promise.
It also not throw error when file is not exists.

iOS: 10 (simulator)
react-native: 0.34.1
path: /Users/raminious/Library/Developer/CoreSimulator/Devices/AFCFB1EA-23C3-4B77-961C-CC431B55D4CF/data/Containers/Data/Application/324FD0EB-73B7-4EE7-9254-3C4B67857D92/Documents/myvid.mp4

@raminious
Copy link
Author

I'm not iOS developer but I changed

presentOpenInMenuFromRect:rootCtrl.view.bounds inView:rootCtrl.view

to

presentOptionsMenuFromRect:rootCtrl.view.bounds inView:rootCtrl.view

And now it's working.

@wkh237
Copy link
Owner

wkh237 commented Oct 15, 2016

@raminious , thanks for the information, I'll try to change the implementation 👍

@raminious
Copy link
Author

raminious commented Oct 15, 2016

Thanks @wkh237
I think as you documented openDocument must open file directly with associated app and previewDocument must show action menu for interact with the file (presentOptionsMenuFromRect)
Currently these functions are working vice versa.

@wkh237
Copy link
Owner

wkh237 commented Oct 15, 2016

Thanks for the advice, if the naming is confusing, I think it's okay to change their name 😄 I'll make these changes and publish another package to npm.

wkh237 added a commit that referenced this issue Oct 16, 2016
@wkh237 wkh237 added the beta label Oct 16, 2016
@wkh237
Copy link
Owner

wkh237 commented Oct 16, 2016

@raminious , I've published 0.10.0-beta.3 to npm, please upgrade to this version and verify the changes, thank you !

@raminious
Copy link
Author

Thanks @wkh237

@camloken
Copy link

camloken commented Nov 25, 2016

One more very important thing... the path must have an extension on the end or it won't work.

e.g. RNFetchBlob.ios.openDocument('path/to/file.ext');

the same is true for previewDocument( ). If your path doesn't have an extension, you can append the extension type on the end of the path using the .config method:

    RNFetchBlob
    .config({
      fileCache: true,
      appendExt: 'jpg', // only append an extension if the res.path() does not return one
    })
    .fetch('GET', attachmentUrl, {
      Authorization: AuthorizationStore.getAuthHeaderValue(),
    })
    .then((res) => {
      // console.log(res.path()) // uncomment this to check if your path has an extension on the end of it
      if (Platform.OS === 'ios') {
        RNFetchBlob.ios.openDocument(res.path()); // results in path/to/file.jpg
      }
    });

I filed the same issue here: #195

@DpkJacob
Copy link

DpkJacob commented Nov 27, 2017

hi @raminious
i am not able to use the openDocument function . i checked wheter the file exists using ,
RNFetchBlob.fs.exists(fs.dirs.DocumentDir+'/sample.pdf') and it does return true. However,
when i try to do this RNFetchBlob.ios.openDocument(fs.dirs.DocumentDir+'/sample.pdf') , it does not do anything nor throw any errors, please help.

zombierabbit pushed a commit to zombierabbit/react-native-fetch-blob that referenced this issue Feb 12, 2019
path sent to unlink is now checked for file prefix.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants