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

result of chooseEntry is not correct #245

Open
Kleak opened this issue Jan 10, 2016 · 3 comments
Open

result of chooseEntry is not correct #245

Kleak opened this issue Jan 10, 2016 · 3 comments
Assignees

Comments

@Kleak
Copy link
Member

Kleak commented Jan 10, 2016

Hi,
when i use chooseEntry it return a ChooseEntryResult object but the fileEntries value of this object is always null.

    chrome.ChooseEntryOptions chooseEntryOptions =
        new chrome.ChooseEntryOptions(type: chrome.ChooseEntryType.OPEN_FILE);
    chrome.ChooseEntryResult chooseEntryResult =
        await chrome.fileSystem.chooseEntry(chooseEntryOptions);
    FileEntry fileEntry;

    print(chooseEntryResult.entry.isFile);
    print(chooseEntryResult.entry.name);

    Metadata meta = await chooseEntryResult.entry.getMetadata();

    print(meta.size);
    print(chooseEntryResult.fileEntries); // this line print null

    if (chooseEntryResult.fileEntries.length == 0) return;
    else {
      fileEntry = chooseEntryResult.fileEntries[0];
    }

If you have an idea, thanks.

@Kleak
Copy link
Member Author

Kleak commented Jan 11, 2016

after more research on that i have follow the chrome sample example here and it seams they cast an Entry to a FileEntry and when i did the same in dart i have :

NoSuchMethodError on the .slice()

    chrome.ChooseEntryOptions chooseEntryOptions =
        new chrome.ChooseEntryOptions(type: chrome.ChooseEntryType.OPEN_FILE);
    chrome.ChooseEntryResult chooseEntryResult =
        await chrome.fileSystem.chooseEntry(chooseEntryOptions);
    Entry entry = chooseEntryResult.entry;
    print(entry.isFile); // print true
    print(entry.name);

    Metadata meta = await chooseEntryResult.entry.getMetadata();
    print(meta.size);

    FileEntry fileEntry = (entry as FileEntry);
    File file = await fileEntry.file();
    Blob blob = file.slice(); // trig a NoSuchMethodError here

@adambender adambender self-assigned this Jan 15, 2016
@adambender
Copy link
Contributor

Wanted to update you that I haven't forgotten this issue, just in the middle of a very busy new year :) I hope to have time to address mid feb.

@BeyondElemental
Copy link

I was also having issues with chooseEntry. I looked into it, and I'm fairly certain it's a bug in the original JavaScript implementation. I ran the following in the console.

chrome.fileSystem.chooseEntry(function(a,b){console.log(a);console.log(b);});
// Returns a FileEntry for a, and undefined for b.

chrome.fileSystem.chooseEntry({acceptsMultiple: true},
    function(a,b){console.log(a);console.log(b);});
// Returns an array of FileEntry for a, and undefined for b.

chrome.fileSystem.chooseEntry({acceptsMultiple: false},
    function(a,b){console.log(a);console.log(b);});
// This also allows selection of multiple files, and is the same as the previous.

Also, I looked into the NoSuchMethodError. In src/files.dart File isn't implemented, so the underlying JsObject is cast to a File from dart:html. However, as far as I can tell the File from dart:html no longer implements JsObject so it doesn't work.

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

No branches or pull requests

3 participants