This repository was archived by the owner on Jan 2, 2025. It is now read-only.
Open
Conversation
Contributor
Author
|
I've made the file api completely asynchronous, it's much closer to the actual file api. I've updated the readme file, but the File section looks a little rough. I'd also appreciate some feedback on |
|
Tested this on his fork and it works great for me. |
|
+1 works |
|
Bump, please just merge this |
|
Bump! |
Open
Member
|
I have merged this PR with master into a new branch called liamks-file-access. I'm keen for someone to have a play with this branch and write some definitive examples of how to use this stuff from the JS side, as I had some trouble making it do its thing. As soon as I have that, I'll merge this back into master. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this commit, developers will now be able to get a list of the absolute paths of files, after a user has selected files from
<input type=file>or from drag and drop. With those absolute file paths text from the file, or a base64 representation of the file can be obtained (useful for images).Design decisions:
WebKit's implementation of the File API is over 8,000 lines of C++ code and includes many dependencies. Fully implementing this would be extensive work. I reasoned that the most important thing, was a text representation and the base64 representation of a file. The code in this commit allows one to get those values. The File API includes the ability to get the Binary representation of a file, that can always be added later.
In the File API a base64 file is prefixed with its mime type. Mac OS X uses Uniform Type Identifiers (UTIs). I've thus added code that translate UTIs of images to mimetypes. It seems though that the base64 encoding of an image can still be displayed without the mimetype.
In the File API file access is asynchronous with events associated with the completion of a file reading. I wasn't able to get that to work unfortunately! However, I think someone with more Objective-c/WebKit experience could take this code and add that functionality. In the mean time I think this is usable.
Please test this first!!!