Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save marchbold/2a0c2108a7e8d5a27b0b96fe8bf10971 to your computer and use it in GitHub Desktop.

Select an option

Save marchbold/2a0c2108a7e8d5a27b0b96fe8bf10971 to your computer and use it in GitHub Desktop.
Create a document using the Cloud Storage ANE
var document:Document = new Document();
document.filename = "uniqueFilename.txt"; // Must be unique in the container
document.data = new ByteArray();
document.data.writeUTFBytes( "TEST SOME STRING WRITING" ); // Some test data
CloudStorage.service.documentStore.addEventListener( DocumentEvent.SAVE_COMPLETE, createCompleteHandler );
CloudStorage.service.documentStore.addEventListener( DocumentEvent.SAVE_ERROR, createErrorHandler );
CloudStorage.service.documentStore.saveDocument( document );
...
private function createCompleteHandler( event:DocumentEvent ):void
{
trace( "document create complete" );
CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_COMPLETE, loadCompleteHandler );
CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_ERROR, loadErrorHandler );
}
private function createErrorHandler( event:DocumentEvent ):void
{
trace( "document create error" );
CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_COMPLETE, loadCompleteHandler );
CloudStorage.service.documentStore.removeEventListener( DocumentEvent.SAVE_ERROR, loadErrorHandler );
}
// com.distriqt.CloudStorage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment