Accessing resources inside polymer elements

71 views
Skip to first unread message

Metronome

unread,
Jun 25, 2015, 9:18:36 PM6/25/15
to mi...@dartlang.org
How do you read files from a compiled dart file?

I have a method like this:
void _getImages() {
  List<String> images = new List<String>();
  //var u=path.fromUri("web/images");
  //print(u);
  var f = new Directory("web/images");
  f.list(recursive: false, followLinks: false)
      .listen((FileSystemEntity entity) {
    images.add(entity.path);
  });
  _createSlideElements(images);
}

However I get an error when running this in chrome: 

Unsupported Operation Platform._operatingSystem

What is the correct way of setting this up?  Eventually I want to be able to pass the path into the component through the template.

Benjamin Strauß

unread,
Jun 26, 2015, 2:12:40 AM6/26/15
to mi...@dartlang.org
To quote the api docs.

https://api.dartlang.org/apidocs/channels/be/dartdoc-viewer/dart:io

"The I/O library is used for Dart server applications, which run on a stand-alone Dart VM from the command line. This library does not work in browser-based applications."

Metronome

unread,
Jul 2, 2015, 4:02:30 AM7/2/15
to mi...@dartlang.org
Well that does end up explaining things.  Thank you.

William Hesse

unread,
Jul 2, 2015, 4:18:18 AM7/2/15
to General Dart Discussion
Inside the Chrome browser, you can use the filesystem API, which gives
you a virtual file system to store things in. This is dead as a W3C
proposal, and will not be implemented on other browsers.

If you want access to the real file system on the machine, Chrome
web apps can access the extra chrome apis, which exit the browser's
sandbox and give you access to the underlying system.

https://developer.chrome.com/apps/fileSystem
> --
> For other discussions, see https://groups.google.com/a/dartlang.org/
>
> For HOWTO questions, visit http://stackoverflow.com/tags/dart
>
> To file a bug report or feature request, go to http://www.dartbug.com/new
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to misc+uns...@dartlang.org.



--
William Hesse
Reply all
Reply to author
Forward
0 new messages