Skip to content

Instantly share code, notes, and snippets.

@karlforshaw
Created March 30, 2010 15:12
Show Gist options
  • Save karlforshaw/349180 to your computer and use it in GitHub Desktop.
Save karlforshaw/349180 to your computer and use it in GitHub Desktop.
@implementation DataDelegate : CPObject
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
{
// Process the data and test it's integrity
CPLog.info('Recieved Data');
var unarchiver = [[CPKeyedUnarchiver alloc] initForReadingWithData:[CPData dataWithString:data]];
var presentation = [unarchiver decodeObjectForKey:"DocumentPresentationKey"];
[unarchiver finishDecoding];
if(! presentation) {
CPLog.error("Presentation data could not be unarchived");
return true;
}
// Create an output stream and export
var pptxFile = tempFileForType("pptx");
var output = new FileOutputStream(pptxFile);
// Write the output
[presentation exportPPTX:output];
}
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPString)error
{
CPLog.error('No Data Recieved: ' + error);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment