This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
German Bauer
Posted Jan 07 - Read on Facebook

Quick question on File I/O - not sure if FramerJS supports this:
- how would I read/write json, text and binary files?
- what if the file is on a server, or I have to ask the user to pick one?
Any examples utmost appreciated!


Jordan Robert Dobson

I know how to read. But not write. It might be possible with CS.

Joel Leví Hernández

A framer prototype is just a web page, you can do an http request on your coffeescript ( which is just sugared JavaScript ) , on phone right now so can't really make an example .

Jordan Robert Dobson

They are running a server to serve up the pages locally. So you might be able to tie into that...

German Bauer

And apparently both mobile safari and chrome are supporting the JS FileReader API so there is hope. Not sure if this is the best path or something better supported by Framer JS...

Mike Feldstein

It'd probably be best for framer studio to just bake the files into the generated js file. Cross browser file support is fraught with peril

Marc Krenn

Reading json-files is easy:

path = "/whatever.json"
json = JSON.parse(Utils.domLoadDataSync(path))

To encode a string into json use JSON.stringify(string)

I can PM you an example if you want to.

German Bauer

So yeah I might get away with simply JSON for one part. What I want to do is:
- have multiple versions of a prototype through an external text config file (json is ok here)
- read and write image files (specifically 9-patch PNGs from Android), using a canvas element to get at the bits

Read the entire post on Facebook