Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added File Access #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Added File Access #25

wants to merge 3 commits into from

Conversation

liamks
Copy link
Contributor

@liamks liamks commented Jan 29, 2012

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!!!

@liamks
Copy link
Contributor Author

liamks commented Jan 30, 2012

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 MacGap/Classes/Commands/File.m regarding code quality.

@winterlightning
Copy link

Tested this on his fork and it works great for me.

@kristoferjoseph
Copy link

+1 works

@winterlightning
Copy link

Bump, please just merge this

@micho
Copy link

micho commented Jun 3, 2012

Bump!

@jeff-h jeff-h mentioned this pull request Feb 22, 2014
@jeff-h
Copy link
Member

jeff-h commented May 27, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants