This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
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!!!