Start a Conversation

Unsolved

This post is more than 5 years old

1210

March 17th, 2015 09:00

How to store a windows directory (folder) on centera?

I can store files (txt, jpg, zip ) on centera and retrieve it back but i want to know is there is a way to store a directory (folder) on centera

208 Posts

March 17th, 2015 10:00

How are you storing the files you mention? That would have a strong bearing on how directories would be stored.

Mike Horgan

208 Posts

March 17th, 2015 11:00

Ah, I thought you might be writing code for this but wasn't sure. How about just creating a .zip of the files in your directory and pushing that up to Centera?

2 Posts

March 17th, 2015 11:00

Here is the store code C#

static void Main(string[] args)

        {

            try

            {

                String clusterAddress = "168.159.214.20?c1profile1.pea";

               String fileName = "e:\\CAS\\ww.zip";//"e:\\CAS\\aa.txt"

                String blobString = "5000";

                int blobThreshold = Int32.Parse(blobString);

               

                if (blobThreshold > 0)

                    FPLogger.ConsoleMessage("\nContent less than " + blobString + " bytes will be embedded in the CDF.");

                else

                    FPLogger.ConsoleMessage("\nContent will never be embedded in the CDF.");

                FPPool.EmbeddedBlobThreshold = blobThreshold;

                 FPPool thePool = new FPPool(clusterAddress);

                // Create the clip

                FPClip clipRef = new FPClip(thePool, fileName);

                clipRef.RetentionExpiry = new DateTime(2015, 10, 10);

  // Or you could set this using a TimeSpan

  //clipRef.RetentionPeriod = new TimeSpan(500, 12, 20, 30);

               

            clipRef.SetAttribute("OriginalFilename", fileName);

            FPTag fileTag = clipRef.AddTag("StoreContentObject");

            fileTag.SetAttribute("filename", fileName);

               

                // Write the content of the file to the Centera

                FPStream streamRef = new FPStream(fileName, 16 * 1024);

                fileTag.BlobWrite(streamRef, FPMisc.OPTION_CLIENT_CALCID);

                streamRef.Close();

                long blobSize = fileTag.BlobSize;

                if (blobThreshold > 0 && blobSize < blobThreshold)

                    FPLogger.ConsoleMessage("\nContent was embedded in the CDF as size "

                        + blobSize

                        + " is less than the threshold.");

                 fileTag.Close();               

                String clipID = clipRef.Write();

                /* Write the Clip ID to the output file, "inputFileName.clipID" */

                String outFileName = fileName + ".clipID";

                FPLogger.ConsoleMessage("\nThe C-Clip ID of the content is " + clipID);

                FileStream outFile = new FileStream(outFileName, FileMode.Create);

                StreamWriter outWriter = new StreamWriter(outFile);

               

                outWriter.Write(clipID.ToString());

                outWriter.Close();

                outFile.Close();

                clipRef.Close();

                thePool.Close();

            }

            catch (FPLibraryException e)

            {

                ErrorInfo err = e.errorInfo;               

                 FPLogger.ConsoleMessage("\nException thrown in FP Library: Error " + err.error + " " + err.message);

            }

        }

March 18th, 2015 05:00

To answer your question: No, there is no way to store a directory on Centera.  If you examine your code closely you'll see that (despite your original post) you are not storing files on Centera, either.  You are storing blobs.

Now, as to a solution, if you wish to simulate storing a directory, you could walk your directory and stream each file to a different blob in your C-Clip, one per tag.  You could use the tag's attributes to store the original file name.

You could also zip them up as Mike Horgan suggested, and store the zip in a single blob.

No Events found!

Top