7

I'm using the free jCIFS library to connect to my NAS device via CIFS, and it's working great. I can connect and get a list of filenames, etc. without any issues.

Now I'd like to open one of the files in the default Android application - i.e. a music file should be opened in the music player, an image in the gallery, video file in a video player and so forth. The issue is not really about getting the MIME type and so on. The issue is that I don't want to download the files first, they should be streamed.

Does anyone know how this can be achieved? I know that CifsManager (another third party application) is capable of doing something similar, but it doesn't use jCIFS and it requires root access to mount drives. It is essential that my application doesn't require root access.

You can find the jCIFS library here: http://jcifs.samba.org/

Michell Bak
  • 12,857
  • 11
  • 60
  • 121

1 Answers1

1

You can use the SmbFileInputStream to read the file.
Please go through the documentation jcifs.smb.SmbFileInputStream

aNi
  • 1,319
  • 10
  • 17
  • I need to launch any selected file in the default viewer in Android, not handle the reading myself - I need to pass it on to another application. Would be great if I could pass on a `FileInputStream`, but I don't think or know if that's possible. – Michell Bak Nov 11 '11 at 06:38
  • 1
    Convert the InputStream to File() and use Intents to open File with the mime type..if you dont know the mime type.. try refering to this http://stackoverflow.com/questions/6265298/action-view-intent-for-a-file-with-unknown-mimetype – aNi Nov 12 '11 at 13:06
  • That won't work - like I said in the question, I don't want to download the files to the device, they need to be streamed. – Michell Bak Nov 12 '11 at 13:15
  • @Michell Bak I'm not sure how you'd accomplish streaming the files, but what I am doing is copying the file to a public path on the device (downloads folder on external storage), opening the file with it's designated application, then deleting the file later on. I did what aNi suggested and it works great for me. – Smitty-Werben-Jager-Manjenson Nov 18 '19 at 21:36