Skip to content

Instantly share code, notes, and snippets.

@yagitoshiro
Created September 28, 2011 09:54

Revisions

  1. yagitoshiro created this gist Sep 28, 2011.
    25 changes: 25 additions & 0 deletions gistfile1.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    save_button.addEventListener('click', ()->

    if Ti.Filesystem.isExternalStoragePresent
    save_image = Ti.Filesystem.getFile(path).read()
    new_path = Titanium.Filesystem.externalStorageDirectory + Date.now().toString() + ".png"
    f = Ti.Filesystem.getFile(new_path)
    result = f.write(save_image)

    unless result
    return null

    callback_fn = (e)->
    Ti.API.info e
    if e.uri
    message = L('saved')
    else
    message = L('error')

    alert message
    return

    Ti.Media.Android.scanMediaFiles([new_path], null, callback_fn)

    return
    )