コード例 #1
0
 private void CleanAccounts(string azureaccountname, string azureaccountkey, string amazons3accountname, string amazons3accountkey)
 {
     AzureHelper helper = new AzureHelper(azureaccountname, azureaccountkey, "foo", CompressionType.None, EncryptionType.None, null, null, new Logger(), 0, 0);
     helper.CleanAccount();
     AmazonS3Helper s3helper = new AmazonS3Helper(new RemoteInfo(amazons3accountname, amazons3accountkey),"foo723r2y3r723rh27r8i", CompressionType.None, EncryptionType.None, null, null, new Logger(), 0, 0);
     s3helper.DeleteAllBuckets();
 }
コード例 #2
0
        public bool UploadToRackSpaceCloudFiles()
        {
            bool syncSucceeded = true;

            try
            {
                var cloudIdentity = new CloudIdentity()
                {
                    APIKey = this.apiKey, Username = this.username
                };
                var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);

                List <string> fileList = AmazonS3Helper.ListFiles(localSource);

                foreach (string file in fileList)
                {
                    cloudFilesProvider.CreateObjectFromFile(container, file, Path.GetFileName(file));
                    // assuming this overwrites file if it exists.
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in uploading to rackspace: " + e);
                syncSucceeded = false;
            }

            return(syncSucceeded);
        }
コード例 #3
0
 /// <summary>
 /// We-use the remote info as: accountName = awsAccessKeyId and accountKey = awsSecretAccessKey
 /// </summary>
 public AmazonS3Synchronizer(RemoteInfo remoteInfo, string bucket, SynchronizeDirection syncDirection, CompressionType compressionType, EncryptionType encryptionType, byte[] encryptionKey, byte[] initializationVector, Logger log, int ChunkSize,  int ThreadPoolSize = 1 )
 {
     this.logger = log;
     disposed = false;
     this.syncDirection = syncDirection;
     bucketName = bucket.ToString().Replace(' ', '-').ToLower(); ;// amazon S3 does not like spaces in bucket names
     
     amazonS3Helper = new AmazonS3Helper(remoteInfo, bucket, compressionType, encryptionType, encryptionKey, initializationVector, logger, ChunkSize, ThreadPoolSize);
     this.MaxConcurrentFileSyncThreads = ThreadPoolSize;
 }
コード例 #4
0
        /// <summary>
        /// We-use the remote info as: accountName = awsAccessKeyId and accountKey = awsSecretAccessKey
        /// </summary>
        public AmazonS3Synchronizer(RemoteInfo remoteInfo, string bucket, SynchronizeDirection syncDirection, CompressionType compressionType, EncryptionType encryptionType, byte[] encryptionKey, byte[] initializationVector, Logger log, int ChunkSize, int ThreadPoolSize = 1)
        {
            this.logger        = log;
            disposed           = false;
            this.syncDirection = syncDirection;
            bucketName         = bucket.ToString().Replace(' ', '-').ToLower();;// amazon S3 does not like spaces in bucket names

            amazonS3Helper = new AmazonS3Helper(remoteInfo, bucket, compressionType, encryptionType, encryptionKey, initializationVector, logger, ChunkSize, ThreadPoolSize);
            this.MaxConcurrentFileSyncThreads = ThreadPoolSize;
        }
コード例 #5
0
        private object UploadFileToBlockBlob_worker(object state)
        {
            string filePath = (string)state;
            bool   retVal   = amazonS3Helper.UploadFileToS3Object(Path.GetFileName(filePath), filePath);

            if (!retVal)
            {
                AmazonS3Helper.structuredLog("E", "UploadFile for {0} failed ", filePath);
            }
            return(null);
        }
コード例 #6
0
        public void AmazonS3ChunkWriteRead()
        {
            string accountName = "";
            string accountKey = "";


            RemoteInfo ri = new RemoteInfo(accountName, accountKey);

            AmazonS3Helper helper = new AmazonS3Helper(new RemoteInfo(accountName, accountKey), "testupl0", CompressionType.GZip, EncryptionType.None, null, null, new Logger(), 4*1024*1024, 1);


            helper.UploadFileAsChunks("D:\\testfiles\\test.txt");
            int OFFSET_TO_READ = 4492321;
            int BYTES_TO_READ = 11000;

            List<ChunkInfo> metadata = helper.GetObjectMetadata("test.txt").Item1;
            Dictionary<int, long> chunkindexandoffsets = helper.GetChunkIndexAndOffsetInChunk(metadata, OFFSET_TO_READ, BYTES_TO_READ);

            byte[] temp = null;

            foreach (int chunkIndex in chunkindexandoffsets.Keys)
            {
                if (temp != null)
                    temp = temp.Concat(helper.DownloadChunk("test.txt", chunkIndex)).ToArray();
                else
                    temp = helper.DownloadChunk("test.txt", chunkIndex);
            }

            byte[] test = temp.Skip((int)chunkindexandoffsets.ElementAt(0).Value).Take(BYTES_TO_READ).ToArray();

            byte[] truth = new byte[BYTES_TO_READ];
            using (BinaryReader reader = new BinaryReader(new FileStream("D:\\testfiles\\test.txt", FileMode.Open)))
            {
                reader.BaseStream.Seek(OFFSET_TO_READ, SeekOrigin.Begin);
                reader.Read(truth, 0, BYTES_TO_READ);
            }

            bool arraysAreEqual = Enumerable.SequenceEqual(test, truth);
            Console.WriteLine(arraysAreEqual);
            if (!arraysAreEqual)
                throw new Exception("local and downloaded bits dont match");

        }