Here i have stucked in simple concept.How to get the file-path when uploading the file in GWT. For example-(d:/example.xls) this is my upload-file. how to get this path programmatically? i have tried this
FileUpload ff=New FileUpload();
ff.getFileName();
when i use above code.it is returning only example.xls only.. help me
You can't access this information from GWT (and javascript in general)
I think, you cannot get the absolute path of a file that you have uploaded. The path will be absent or changed to avoid security risks, after you have done the upload.
You can get the file's name using the getFileName() function,
and even its content, with the HTML5 FileAPI.
Related
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 would I know that it is file or a directory , cause I have to check a condition that if it is a file then return a particular image for the files and if it is directory then return different image for that,
isDirectory() and isFile() method are not working in GWT.
Kindly give the solution for GWT.
Try to use GWT Elemental. It brings a HTML5 File API (besides WebGL, WebAudio, Shadow DOM,...), with which you should check if it is a directory or file (on client-side):
FileEntry fileEntry = (FileEntry)entry;
fileEntry.isDirectory();
fileEntry.isFile();
You should be doing such operations on the server side. You can always create a bean with the required properties which can be used on the client side.
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
I want to enhance this question. How can I create File Destination Chooser (as like JFileChooser) in GWT?
I had googled for a long time to get it in GWT. I found GWT FileUpload in most.
Any Suggestions for it ?
UPDATE: After clearing on question
Well, for this you would need a Download Servlet for the file. There in HttpServletResponse you will fill the content with the file and header with file types and all.
And from your client side call the URL.
For prompting case, it depends upon the browser configuration. You cannot force browser to open location prompt.
For achieving download only, you can refer to download file using gwt
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