sending .txt file to dropbox using code (without needing to press 'sync')

Hello everybody,

I am creating an App for a research project. I have made an app that allows a user to draw their house plan. This house plan is written to a string which can be saved to a txt file and sent to dropbox.spritepack folder. However this txt file only updates in my real dropbox AFTER I hit ‘sync’ on my ipad, this is a cumbersome step and I was wondering whether there was a way to make it sync automatically or after I hit a button in my app?

Alternatively, is there a way to ‘export’ my houseplan txt file to a local folder in case internet connectivity is not available? - also all done in the app and not needing to manually ‘sync’?

I appreciate all help I can get.

YK

I have found this method http://twolivesleft.com/Codea/Talk/discussion/1380/example-storing-data-in-the-coud/p1 which I will use for the ‘online’ export, but I am also looking for a ‘offline’ method

Cheers,
YK

@archistudent you can save to your documents folder on the ios device.

Cool - What is the link to the documents folder?

Also what is the easiest way to access this folder or is there a way this automatically updates on dropbox? This app will be used all over the country and by lay persons with not much computer literacy.

Cheers,
YK

@archistudent Here’s an example of writing and reading a file to/from the documents folder. The file has to have a .png extension to show up in the documents folder. It could have a .txt or other extension and it will still be there, but just not visible.


function setup()   
    local file = os.getenv("HOME").."/Documents/testfile.png"
    local text = "This is some sample text."
    writeTest(file,text)
    readTest(file)
end

function writeTest(file,txt)
    print("writing file")
    io.output(io.open(file,"w"))
    io.write(txt)
    io.close()
    print("write done")
end

function readTest(file)
    print("reading file")
    io.input(io.open(file,"r"))
    for i in io.lines() do
        print(i) 
    end
    print("read done")
end