FolioReader-Android
FolioReader-Android copied to clipboard
Read epub without saving in local storage
Feature - Read epub without saving in local storage FolioReader version - 0.5.4 Android SDK - 28
I can see the FR can only epub file from assets, raw or file path from storage. I can also see that FR library is saving epub in temp location in external storage.
Is there any way to read an epub file without saving in the temp location?
Restrict the epub file access to the current application only. Maybe encrypt the epub file and pass the encrypted epub file path to FR.
Feature - Read epub without saving in local storage FolioReader version - 0.5.4 Android SDK - 28
I can see the FR can only epub file from assets, raw or file path from storage. I can also see that FR library is saving epub in temp location in external storage.
Is there any way to read an epub file without saving in the temp location?
Restrict the epub file access to the current application only. Maybe encrypt the epub file and pass the encrypted epub file path to FR.
or from inputStream
@munnadroid as a workaround, you can do the following:
- request permissions:
(
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE
) - I guess your source comes from network, so you may use something like this:
val targetPath = context.getExternalFilesDir(null)+ "/temp_dir/temp_file.epub"
"https://path.to.epub".saveTo(targetPath)
Folioreader.get().openBook(targetPath)
private fun String.saveTo(path: String) {
URL(this).openStream().use { input ->
FileOutputStream(File(path)).use { output ->
input.copyTo(output)
}
}
}
- last part is cleanup - during usage you already created a file on device:
val tempFIle = File(targetPath)
then, remove file usingtempFile.delete()
if no longer needed, ortempFile.deleteOnExit()
(removes file when virtual machine is terminated) make sure during file operations to close all streams, otherwise delete could won't work: https://stackoverflow.com/questions/24758520/deleteonexit-not-deleting-file/28751091
@munnadroid as a workaround, you can do the following:
- request permissions: (
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE
)- I guess your source comes from network, so you may use something like this:
val targetPath = context.getExternalFilesDir(null)+ "/temp_dir/temp_file.epub"
"https://path.to.epub".saveTo(targetPath)
Folioreader.get().openBook(targetPath)
private fun String.saveTo(path: String) { URL(this).openStream().use { input -> FileOutputStream(File(path)).use { output -> input.copyTo(output) } } }
- last part is cleanup - during usage you already created a file on device:
val tempFIle = File(targetPath)
then, remove file usingtempFile.delete()
if no longer needed, ortempFile.deleteOnExit()
(removes file when virtual machine is terminated) make sure during file operations to close all streams, otherwise delete could won't work: https://stackoverflow.com/questions/24758520/deleteonexit-not-deleting-file/28751091
yes, but it can be accessed by a user with root access, like rooted phones