How to get local path of file in Flutter web - flutter

I'm using file_picker which give the path to the file in mobile, but in web the path is always null.
I read somewhere you can get the bytes of the file, but I couldn't understand how this it's done.
Right now I am trying to pick a video and showed on my web page with video_player, this method accepts a File.
So, is it possible to get the path of my video somehow and transformed to File?

Related

Flutter - Pick files and get their path or URI

With file_picker, I can't get file's real path or URI from FilePicker.platform.pickFiles(). It only returned something like this
/data/user/0/my_app_dir/cache/file_picker/file
and logged this
I/FilePickerUtils(27005): Caching from URI: content://com.android.providers.media.documents/document/video%3A1519
D/FilePickerUtils(27005): File loaded and cached
at:/data/user/0/my_app_dir/cache/file_picker/file
D/FilePickerDelegate(27005): File path:[com.mr.flutter.plugin.filepicker.FileInfo#705d9ef]
That's not what I want. I just want the real original absolute file path, the file information, regardless of what I'll going to do with the file. So I'm looking for a package that do that or the solution how to manually pick file and get the file path like I could do natively. Thank you in advance.
It's not impossible with native code. It's just package publisher who made it unavailable using it. Follow this to implement file path picker on native code. It works for me.

How to read a file in Flutter server side

I've looked up many topic but none seems to do what i need.
I am working on a website with flutter and i need to read a file thats located on the server.
Is this in any way possible?
Edit: The contents in this file change, so i have to update the contents on the website.
If you want to be able to access the file as if it was locally stored, then it needs to be registered under your assets in your pubspec.yaml & should be included in the project itself. Otherwise, you will have to fetch the file using something like DIO to fetch it from wherever it is hosted.

IONIC 4: How to call iOs file resource from custom script within app

Here is the situation:
Ionic 4: (cli-5.2.7)
XCode 10.3
We have a custom eReader that lives in our assets folder.
When we want to download an eBook from our server and read it, we download the file and save it using the Native File plugin.
When we start up the reader, we send it the container in which we want the reader to be created and built, and an internal url to the file resource we want to read.
After window.Ionic.WebView.convertFileSrc, the file ref looks like:
ionic://localhost/_app_file_/var/mobile/Containers/Data/Application/[APP-ID]/Library/NoCloud/[BOOK-ID]/vol-001-chapter-006.xhtml
The reader will then build the iframe and send a simple XMHttpRequest to the provided url, then place the resulting html into the iframe.
The problem is that it only works on first load of the eBook from our server
I can see the file being downloaded, and written to its own folder in the apps file system (File.dataDirectory).
When I debug the XMLHttpRequest in our eReader.js, I can see the call being made to the resource and the HTML returning to the request, which is then rendered on the page.
BUT, if I close the app, reopen it, and try to access the already-downloaded book, the XMLHttpRequest in our eReader.js returns nothing.
I can verify that the file exists at the resource location after a reload, but the XMLHttpRequest acts like it cannot find anything at the provided location.
AND, this is only on iOs. Android works as intended.
My questions is, what am I missing? Is this something to do with the iOs permissions or persistence?
Any help would be appreciated.

Access downloaded pdf file path in HTML5 file system and display it in webview

In my chrome app, I am using HTML5 file system to save the pdf files to sand box.Downloading is working fine.But how do i access that downloaded file path? I want to give that path as webview source.
The best way, if it works, would be to use a filesystem URL. To get this use FileEntry.toURL
These don't work on external files (i.e. files that come from chrome.fileSystem.chooseEntry and are outside the app's sandbox) but should work for files in the app's sandbox.
Note, I am referring to filesystem:// urls not file://urls, which won't work as Marc Rochkind has pointed out in his answer.
Disclaimer: I haven't tested this, but I believe it should work.
You need to get the contents of the PDF into a data URL. See my answer to this question:
Download external pdf files to chrome packaged app's file system

With filepicker.io, is there a way to get the original file path?

I am using filepicker.io and specially computer as main service.
I would like to get the original file path of a file uploaded through the API.
For example, if I upload a file located at /my/path/in/my/computer/file.zip, I will get in the FPFile object the filepicker.io URL but not the original file path.
Is there a way to get it ?
PS: I have tried to retrieve the stat of the file too without success.
Due to browser security limitations, the real local path of the file is never exposed to the javascript application. For more information, see http://davidwalsh.name/fakepath