Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8216175

File API and FileReader should be supported in WebView

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • jfx12
    • javafx
    • None
    • web
    • behavioral
    • minimal
    • This implements existing HTML functionality with no new API and poses no compatibility risk.
    • File or wire format
    • JDK

      Summary

      Provide FileReader support in JavaFX webview so that application developers can have the ability to read the file contents (as a whole/slice ) via JavaSciript. in an asynchronous manner. This change supports reading multiple files also.

      Problem

      Currently webkit has support for interfaces like File, FileList, Blob and FileReader. But JavaFX webview does not have the implementation for FileReader, due to which the application developers are not able to read the file contents via JavaScript.

      Solution

      Since webkit has support for FileReader, we have to implement the missing file related functionality in java webkit port. From native code , we implemented methods like openFile, readFromFile, seekFile and closeFile (in FileSystemJava.cpp) and the corresponding JNI calls are implemented like fwkOpenFile, fwkReadFromFile, fwkSeekFile and fwkCloseFile in FileSystem.java. We opted for RandomAccessFile to create file from java.

      Currently we don't support reading file contents via drag and drop API.

      webrev: https://github.com/javafxports/openjdk-jfx/pull/250

      Specification

      We provide support in WebView for the following HTML5 FileReader methods, which the application developer can call from JavaScript:

      FileReader:

      • readAsArrayBuffer()

      • readAsBinaryString()

      • readAsDataURL()

      • readAsText()

      • abort()

      Also refer to the attached FileReader.patch.

            mbilla Murali Billa
            shadowbug Shadow Bug
            Kevin Rushforth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: