static void Main(string[] args) { IntPtr userData = new IntPtr(0); string clipID; BinaryReader myReader; BinaryWriter myWriter; BlobStream myStream; // For thsi test we are using a file as the input. *Any* stream could be used. // This would be your test PDF - in a file or memory stream. FileStream inputStream = new FileStream("e:\\testfile", FileMode.Open); FPLogger.ConsoleMessage("\nInput file length " + inputStream.Length); try { FPLogger log = new FPLogger(); log.LogPath = "C:\\GenStreamsLog.txt"; log.Start(); // Create a test clip demonstrating how to write a blob using a stream FPPool myPool = new FPPool("cse1.centera.lab.emc.com"); FPClip myClip = myPool.ClipCreate("GenericStreamWrite_testClip"); FPTag myTag = myClip.AddTag("testTag"); // Simple test of the BlobWriteStream - write contents of a local file // to Centera using a StreamReader and StreamWriter // We are using a temporary MemoryStream for our staging area myStream = new BlobWriteStream(myTag); myReader = new BinaryReader(inputStream); myWriter = new BinaryWriter(myStream); long writeTime1 = DateTime.Now.Ticks; myWriter.Write(myReader.ReadBytes((int)inputStream.Length)); myWriter.Flush(); ((BlobWriteStream)myStream).Close(); // If we don't do this it will stay open forever with keep alives! writeTime1 = DateTime.Now.Ticks - writeTime1; // If we assign values to existing FP objects we must explicitly close // them first to avoid potential "Object In Use" errors on future closure myTag.Close(); myTag = myClip.AddTag("SlicedBlob"); inputStream.Seek(0, SeekOrigin.Begin); long writeTime = DateTime.Now.Ticks; SlicedBlobWriter.Instance(inputStream, myTag, 8); writeTime = DateTime.Now.Ticks - writeTime; myTag.Close(); clipID = myClip.Write(); myClip.Close(); FPLogger.ConsoleMessage("\nGenericStreamWrite test succeeded " + clipID); // Now we will test reading it back from the Centera { myClip = myPool.ClipOpen(clipID, FPMisc.OPEN_ASTREE); myTag = myClip.NextTag; // Here we create a stream to read back the blob long readTime1 = DateTime.Now.Ticks; myStream = new BlobReadStream(myTag); // This is only to test to verify when we read the content back it is the same as the // input file i.e. we are going to store it on the file system and then use file system tools // to compare the files myReader = new BinaryReader(myStream); myWriter = new BinaryWriter(new FileStream("c:\\testfile2.out", FileMode.Create)); ((BlobReadStream)myStream).Join(); myWriter.Write(myReader.ReadBytes((int)myTag.BlobSize)); myWriter.Flush(); myStream.Close(); readTime1 = DateTime.Now.Ticks - readTime1; myTag.Close(); // This shows how to read content back using multiple threads myTag = myClip.NextTag; long readTime = DateTime.Now.Ticks; SlicedBlobReader.Instance(new FileStream("c:\\testfile2.out.sliced", FileMode.Create), myTag, 8); readTime = DateTime.Now.Ticks - readTime; myTag.Close(); myClip.Close(); myPool.Close(); FPLogger.ConsoleMessage("\nSerial tests - Write time: " + TimeSpan.FromTicks(writeTime1) + " Read time " + TimeSpan.FromTicks(readTime1)); FPLogger.ConsoleMessage("\nMulti threaded tests - Write time: " + TimeSpan.FromTicks(writeTime) + " Read time " + TimeSpan.FromTicks(readTime)); } catch (FPLibraryException e) { ErrorInfo err = e.errorInfo; FPLogger.ConsoleMessage("\nException thrown in FP Library: Error " + err.error + " " + err.message); } }