Exemple #1
0
        public static bool Write_File_To_S3(String path, String key_name)
        {
            DateTime before = DateTime.Now;
            try
            {
                // simple object put
                PutObjectRequest request = new PutObjectRequest();
                request.WithFilePath(path)
                    .WithBucketName(bucketName)
                    .WithKey(key_name);

                S3Response response = s3_client.PutObject(request);
                response.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception n Write_File_To_S3(String path=" + path + ", String key_name=" + key_name + "). e.Message="+e.Message);
                Console.WriteLine("Write_File_To_S3(String path=" + path + ", String key_name=" + key_name + ") failed!!!");
                return false;
            }
            TimeSpan uploadTime = DateTime.Now - before;
            Console.WriteLine("Uploading " + path + " into S3 Bucket=" + bucketName + " , key=" + key_name + " took " + uploadTime.TotalMilliseconds.ToString() + " milliseconds");

            return true;
        }
Exemple #2
0
 public static string CreateNewFileInFolder(AmazonS3 client, string foldername, string filepath)
 {
     String S3_KEY = foldername + "/" + System.IO.Path.GetFileName(filepath);
     PutObjectRequest request = new PutObjectRequest();
     request.WithBucketName(BUCKET_NAME);
     request.WithKey(S3_KEY);
     request.WithFilePath(filepath);
     //request.WithContentBody("This is body of S3 object.");
     client.PutObject(request);
     return S3_KEY;
 }
Exemple #3
0
        public string InsertObject(string filePath, string keyName)
        {
            var putRequest = new PutObjectRequest();

            putRequest.WithFilePath(filePath)
                .WithBucketName(BucketName)
                .WithKey(keyName)
                .WithCannedACL(S3CannedACL.PublicRead);

            using (AmazonS3 client = AWSClientFactory.CreateAmazonS3Client(AccessKeyId, SecretAccessKeyId))
            {
                S3Response putResponse = client.PutObject(putRequest);

                return string.Format("http://s3.amazonaws.com/{0}/{1}", BucketName, keyName);
            }
        }
         public bool UploadFileToS3Object(string s3ObjectName, string filePath)
         {

             try
             {
                 PutObjectRequest request = new PutObjectRequest();
                 request.WithBucketName(bucketName);
                 request.WithKey(s3ObjectName);
                 request.WithFilePath(filePath);//request.WithContentBody
                 amazonS3Client.PutObject(request);
                 return true;
             }
             catch (Exception e)
             {
                 structuredLog("E", "Exception in UploadFileToS3Object: "+e);
                 return false;
             }

         }
 public static bool WriteLogFile(string uploadFilePath, string credentialFilePath)
 {
     Type t = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
     LogEvents.S3UploadStarted(t, uploadFilePath);
     try
     {
         if(ReadS3Credentials(credentialFilePath) == false)
         {
             LogEvents.S3NoCredentials(t);
             return false;
         }
         AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(_accessKeyId, _secretAccessKey);
         PutObjectRequest request = new PutObjectRequest();
         string fileName = System.IO.Path.GetFileName(uploadFilePath);
         request.WithFilePath(uploadFilePath).WithBucketName(_bucketName).WithKey(fileName);
         S3Response responseWithMetadata = client.PutObject(request);
         return true;
     }
     catch (AmazonS3Exception amazonS3Exception)
     {
         LogEvents.S3Error(t, amazonS3Exception);
         return false;
     }
 }
        private static void UploadFile(string filePath, string key, string bucket)
        {
            string AWSAccessKey = ConfigurationManager.AppSettings["AWSAccessKey"];
            string AWSSecretKey = ConfigurationManager.AppSettings["AWSSecretKey"];

            using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey))
            {
                PutObjectRequest request = new PutObjectRequest();
                request.WithBucketName(bucket);
                request.WithKey(key);
                request.WithFilePath(filePath);
                request.CannedACL = S3CannedACL.PublicRead;

                client.PutObject(request);
            }
        }
Exemple #7
0
        public static void ACLSerial(String filePath)
        {
            System.Console.WriteLine("\nhello,ACL!!");
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(appConfig["AWSAccessKey"], appConfig["AWSSecretKey"]);
            String bucketName = "chutest";
            String objectName = "hello";
            //versioning test
            String vbucketName = "netversion";

            //**********************************************************************************************************************************************************
            // Set Version test 環境,目前新增一專用 bucket = netversion,內有兩筆 Object 資訊(Object 已刪除,帶有 delete marker),為了測試方便,此環境不共用也不刪除
            // 若於佈板後刪除環境,請預先建立環境,執行132~150行程式
            //**********************************************************************************************************************************************************

            //PutBucket
            /*    System.Console.WriteLine("PutBucket-version: {0}\n", vbucketName);
                s3Client.PutBucket(new PutBucketRequest().WithBucketName(vbucketName));

                //PutBucketVersioning
                SetBucketVersioningResponse putVersioningResult = s3Client.SetBucketVersioning(new SetBucketVersioningRequest().WithBucketName(vbucketName).WithVersioningConfig(new S3BucketVersioningConfig().WithStatus("Enabled")));
                System.Console.WriteLine("PutBucketVersioning, requestID:{0}\n", putVersioningResult.RequestId);

                //PutObject
                System.Console.WriteLine("PutObject!");
                PutObjectRequest objectVersionRequest = new PutObjectRequest();
                objectVersionRequest.WithBucketName(vbucketName);
                objectVersionRequest.WithKey(objectName);
                objectVersionRequest.WithFilePath(filePath);
                PutObjectResponse objectVersionResult = s3Client.PutObject(objectVersionRequest);
                System.Console.WriteLine("Uploaded Object Etag: {0}\n", objectVersionResult.ETag);

                //DeleteObject
                System.Console.WriteLine("Delete Object!");
                s3Client.DeleteObject(new DeleteObjectRequest().WithBucketName(vbucketName).WithKey(objectName));
            */

            //PutBucket
            System.Console.WriteLine("PutBucket: {0}\n", bucketName);
            s3Client.PutBucket(new PutBucketRequest().WithBucketName(bucketName));

            //PutObject
            System.Console.WriteLine("PutObject!");
            PutObjectRequest request = new PutObjectRequest();
            request.WithBucketName(bucketName);
            request.WithKey(objectName);
            request.WithFilePath(filePath);
            PutObjectResponse PutResult = s3Client.PutObject(request);
            System.Console.WriteLine("Uploaded Object Etag: {0}\n", PutResult.ETag);

            //PutBucketACL
            SetACLRequest aclRequest = new SetACLRequest();
            S3AccessControlList aclConfig = new S3AccessControlList();
            aclConfig.WithOwner(new Owner().WithDisplayName("hrchu").WithId("canonicalidhrchu"));
            aclConfig.WithGrants(new S3Grant().WithGrantee(new S3Grantee().WithCanonicalUser("canonicalidhrchu","hrchu")).WithPermission(S3Permission.FULL_CONTROL));
            aclConfig.WithGrants(new S3Grant().WithGrantee(new S3Grantee().WithCanonicalUser("canonicalidannyren", "annyren")).WithPermission(S3Permission.READ_ACP));

            aclRequest.WithBucketName(bucketName);
            aclRequest.WithACL(aclConfig);

            SetACLResponse putBucketACLResult = s3Client.SetACL(aclRequest);
            System.Console.WriteLine("\nPutBucketACL, requestID:{0}",putBucketACLResult.RequestId);

            //GetBucketACL
            GetACLResponse getBucketACLResult = s3Client.GetACL(new GetACLRequest().WithBucketName(bucketName));
            System.Console.WriteLine("\nGetBucketACL Result:\n{0}\n",getBucketACLResult.ResponseXml);

            //**********************************************************************************************************************************************************

            //PutBucketACL (cannedacl)
            SetACLRequest cannedaclRequest = new SetACLRequest();
            cannedaclRequest.WithBucketName(bucketName);
            cannedaclRequest.WithCannedACL(S3CannedACL.PublicRead);

            SetACLResponse putBucketCannedACLResult = s3Client.SetACL(cannedaclRequest);
            System.Console.WriteLine("\nPutBucketCannedACL, requestID:{0}", putBucketCannedACLResult.RequestId);

            //GetBucketACL
            GetACLResponse getBucketCannedACLResult = s3Client.GetACL(new GetACLRequest().WithBucketName(bucketName));
            System.Console.WriteLine("\nGetBucketCannedACL Result:\n{0}\n", getBucketCannedACLResult.ResponseXml);

            //**********************************************************************************************************************************************************

            //PutObjectACL
            SetACLRequest objectACLRequest = new SetACLRequest();
            S3AccessControlList objectACLConfig = new S3AccessControlList();
            objectACLConfig.WithOwner(new Owner().WithDisplayName("hrchu").WithId("canonicalidhrchu"));
            objectACLConfig.WithGrants(new S3Grant().WithGrantee(new S3Grantee().WithCanonicalUser("canonicalidhrchu", "hrchu")).WithPermission(S3Permission.FULL_CONTROL));
            objectACLConfig.WithGrants(new S3Grant().WithGrantee(new S3Grantee().WithCanonicalUser("canonicalidannyren", "annyren")).WithPermission(S3Permission.WRITE_ACP));

            objectACLRequest.WithBucketName(bucketName);
            objectACLRequest.WithKey(objectName);
            objectACLRequest.WithACL(objectACLConfig);

            SetACLResponse putObjectACLResult = s3Client.SetACL(objectACLRequest);
            System.Console.WriteLine("\nPutObjectACL, requestID:{0}", putObjectACLResult.RequestId);

            //GetObjectACl
            GetACLResponse getObjectACLResult = s3Client.GetACL(new GetACLRequest().WithBucketName(bucketName).WithKey(objectName));
            System.Console.WriteLine("\nGetObjectACL Result:\n{0}\n", getObjectACLResult.ResponseXml);

            //**********************************************************************************************************************************************************

            //PutObjectACL (cannedacl)
            SetACLRequest objectCannedACLRequest = new SetACLRequest();

            objectCannedACLRequest.WithBucketName(bucketName);
            objectCannedACLRequest.WithKey(objectName);
            objectCannedACLRequest.WithCannedACL(S3CannedACL.PublicRead);

            SetACLResponse putObjectCannedACLResult = s3Client.SetACL(objectCannedACLRequest);
            System.Console.WriteLine("\nPutObjectCannedACL, requestID:{0}", putObjectCannedACLResult.RequestId);

            //GetObjectACl
            GetACLResponse getObjectCannedACLResult = s3Client.GetACL(new GetACLRequest().WithBucketName(bucketName).WithKey(objectName));
            System.Console.WriteLine("\nGetObjectCannedACL Result:\n{0}\n", getObjectCannedACLResult.ResponseXml);

            //**********************************************************************************************************************************************************

            //DeleteObject
            System.Console.WriteLine("Delete Object!");
            s3Client.DeleteObject(new DeleteObjectRequest().WithBucketName(bucketName).WithKey(objectName));
            //DeleteBucket
            System.Console.WriteLine("Delete Bucket!");
            s3Client.DeleteBucket(new DeleteBucketRequest().WithBucketName(bucketName));

            //PutObjectACL-version test*********************************************************************************************************************************
            String versionid = "784cca47e2a7423f97dedde6a72f9b3d";

            //PutObjectACL-versionid
              SetACLRequest objectVersionACLRequest = new SetACLRequest();
              S3AccessControlList objectVersionACLConfig = new S3AccessControlList();
              objectVersionACLConfig.WithOwner(new Owner().WithDisplayName("hrchu").WithId("canonicalidhrchu"));
              objectVersionACLConfig.WithGrants(new S3Grant().WithGrantee(new S3Grantee().WithCanonicalUser("canonicalidhrchu", "hrchu")).WithPermission(S3Permission.FULL_CONTROL));
              objectVersionACLConfig.WithGrants(new S3Grant().WithGrantee(new S3Grantee().WithCanonicalUser("canonicalidannyren", "annyren")).WithPermission(S3Permission.WRITE_ACP));

              objectVersionACLRequest.WithBucketName(vbucketName);
              objectVersionACLRequest.WithKey(objectName);
              objectVersionACLRequest.WithVersionId(versionid);
              objectVersionACLRequest.WithACL(objectVersionACLConfig);

              SetACLResponse putObjectVersionACLResult = s3Client.SetACL(objectVersionACLRequest);
              System.Console.WriteLine("\nPutObjectACL Version, requestID:{0}", putObjectVersionACLResult.RequestId);

              //GetObjectACl-versionid
              GetACLResponse getObjectVersionACLResult = s3Client.GetACL(new GetACLRequest().WithBucketName(vbucketName).WithKey(objectName).WithVersionId(versionid));
              System.Console.WriteLine("\nGetObjectACL Version Result:\n{0}\n", getObjectVersionACLResult.ResponseXml);

              //PutObjectACL (cannedacl)-versionid
              SetACLRequest objectVersionCannedACLRequest = new SetACLRequest();

              objectVersionCannedACLRequest.WithBucketName(vbucketName);
              objectVersionCannedACLRequest.WithKey(objectName);
              objectVersionCannedACLRequest.WithVersionId(versionid);
              objectVersionCannedACLRequest.WithCannedACL(S3CannedACL.PublicRead);

              SetACLResponse putObjectVersionCannedACLResult = s3Client.SetACL(objectVersionCannedACLRequest);
              System.Console.WriteLine("\nPutObjectCannedACL Version, requestID:{0}", putObjectVersionCannedACLResult.RequestId);

              //GetObjectACl(cannedacl)-versionid
              GetACLResponse getObjectVersionCannedACLResult = s3Client.GetACL(new GetACLRequest().WithBucketName(vbucketName).WithKey(objectName).WithVersionId(versionid));
              System.Console.WriteLine("\nGetObjectCannedACL Version Result:\n{0}\n", getObjectVersionCannedACLResult.ResponseXml);

            System.Console.WriteLine("END!");
        }
Exemple #8
0
        /// <summary>
        /// Publishes a file to Amazon S3.
        /// </summary>
        /// <param name="filePath">The path of the file to publish.</param>
        private void PublishFile(string filePath)
        {
            NameValueCollection headers = new NameValueCollection();
            string contentType = MimeType.FromCommon(filePath).ContentType;
            string objectKey = this.ObjectKey(filePath);

            if (this.OverwriteExisting || !this.ObjectExists(objectKey))
            {
                PutObjectRequest request = new PutObjectRequest()
                    .WithBucketName(this.BucketName)
                    .WithCannedACL(S3CannedACL.PublicRead)
                    .WithContentType(contentType)
                    .WithKey(objectKey)
                    .WithTimeout(this.Timeout);

                bool gzip = false;
                string tempPath = null;

                if (contentType.StartsWith("text", StringComparison.OrdinalIgnoreCase))
                {
                    gzip = true;
                    tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Path.GetRandomFileName());

                    using (FileStream fs = File.OpenRead(filePath))
                    {
                        using (FileStream temp = File.Create(tempPath))
                        {
                            using (GZipStream gz = new GZipStream(temp, CompressionMode.Compress))
                            {
                                byte[] buffer = new byte[4096];
                                int count;

                                while (0 < (count = fs.Read(buffer, 0, buffer.Length)))
                                {
                                    gz.Write(buffer, 0, count);
                                }
                            }
                        }
                    }

                    headers["Content-Encoding"] = "gzip";
                    request = request.WithFilePath(tempPath);
                }
                else
                {
                    request = request.WithFilePath(filePath);
                }

                request.AddHeaders(headers);

                using (PutObjectResponse response = this.Client().PutObject(request))
                {
                }

                if (!String.IsNullOrEmpty(tempPath) && File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }

                this.PublisherDelegate.OnFilePublished(filePath, objectKey, gzip);
            }
            else
            {
                this.PublisherDelegate.OnFileSkipped(filePath, objectKey);
            }
        }
Exemple #9
0
 public static string UploadFile(AmazonS3 client, string filepath)
 {
     //S3_KEY is name of file we want upload
     S3_KEY = System.IO.Path.GetFileName(filepath);
     PutObjectRequest request = new PutObjectRequest();
     request.WithBucketName(BUCKET_NAME);
     request.WithKey(S3_KEY);
     //request.WithInputStream(MemoryStream);
     request.WithFilePath(filepath);
     client.PutObject(request);
     return S3_KEY;
 }
Exemple #10
0
        public static void objectSerial(String filePath)
        {
            System.Console.WriteLine("\nhello,object!!");
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(appConfig["AWSAccessKey"], appConfig["AWSSecretKey"]);
            String bucketName = "chttest3";
            String objectName = "hello";
            //String filePath = "D:\\Visual Studio Project\\TestNetSDK\\TestNetSDK\\pic.jpg";

            //PutBucket
            System.Console.WriteLine("PutBucket: {0}\n",bucketName);
            PutBucketResponse response = s3Client.PutBucket(new PutBucketRequest().WithBucketName(bucketName));

            //PutObject
            System.Console.WriteLine("PutObject!\n");
            PutObjectRequest request = new PutObjectRequest();
            request.WithBucketName(bucketName);
            request.WithKey(objectName);
            request.WithFilePath(filePath);
            PutObjectResponse PutResult = s3Client.PutObject(request);
            System.Console.WriteLine("Uploaded Object Etag: {0}\n", PutResult.ETag);

            //HeadObject
            System.Console.WriteLine("HeadObject!\n");
            GetObjectMetadataResponse HeadResult = s3Client.GetObjectMetadata(new GetObjectMetadataRequest().WithBucketName(bucketName).WithKey(objectName));
            System.Console.WriteLine("HeadObject: (1)ContentLength: {0} (2)ETag: {1}\n", HeadResult.ContentLength,HeadResult.ETag);

            //GetObject
            System.Console.WriteLine("GetObject!\n");
            GetObjectResponse GetResult =  s3Client.GetObject(new GetObjectRequest().WithBucketName(bucketName).WithKey(objectName).WithByteRange(1,15));

            Stream responseStream = GetResult.ResponseStream;
            StreamReader reader = new StreamReader(responseStream);
            System.Console.WriteLine("Get Object Content:\n {0}\n", reader.ReadToEnd());

            System.Console.WriteLine("Get Object ETag:\n {0}\n", GetResult.ETag);

            //CopyObject
            CopyObjectResponse CopyResult = s3Client.CopyObject(new CopyObjectRequest().WithSourceBucket(bucketName).WithSourceKey(objectName).WithDestinationBucket(bucketName).WithDestinationKey("hihi"));
            System.Console.WriteLine("CopyObject: ETag: {0} \n",CopyResult.ETag);

            //DeleteObject
            System.Console.WriteLine("Delete Object!\n");
            s3Client.DeleteObject(new DeleteObjectRequest().WithBucketName(bucketName).WithKey(objectName));
            s3Client.DeleteObject(new DeleteObjectRequest().WithBucketName(bucketName).WithKey("hihi")); //copied object

            //==============================jerry add ==============================
            System.Console.WriteLine("Jerry Add!\n");
            String objectName2 = "hello2";
            NameValueCollection nvc = new NameValueCollection();
            nvc.Add("A", "ABC");

            System.Console.WriteLine("PutObject!\n");
            PutObjectRequest request2 = new PutObjectRequest();
            request2.WithBucketName(bucketName);
            request2.WithKey(objectName2);
            request2.WithAutoCloseStream(true);
            request2.WithCannedACL(S3CannedACL.BucketOwnerFullControl);
            request2.WithContentBody("test");
            request2.WithContentType("test/xml");
            request2.WithGenerateChecksum(true);
            request2.WithMD5Digest("CY9rzUYh03PK3k6DJie09g==");

            request2.WithMetaData(nvc);
            request2.WithWebsiteRedirectLocation("http://hicloud.hinet.net/");
            PutObjectResponse PutResult2 = s3Client.PutObject(request2);
            System.Console.WriteLine("Uploaded Object Etag: {0}\n", PutResult2.ETag);

            System.Console.WriteLine("GetObject!\n");
            GetObjectRequest request3 = new GetObjectRequest();
            request3.WithBucketName(bucketName);
            request3.WithKey(objectName2);
            request3.WithByteRange(1, 2);
            DateTime datetime = DateTime.UtcNow;
            // 似乎不支援 datetime
            request3.WithModifiedSinceDate(datetime.AddHours(-1));
            request3.WithUnmodifiedSinceDate(datetime.AddHours(1));
            request3.WithETagToMatch(PutResult2.ETag);
            request3.WithETagToNotMatch("notMatch");
            GetObjectResponse GetResult2 = s3Client.GetObject(request3);
            Stream responseStream2 = GetResult2.ResponseStream;
            StreamReader reader2 = new StreamReader(responseStream2);
            System.Console.WriteLine("Get Object Content(es):\n {0}\n", reader2.ReadToEnd());
            System.Console.WriteLine("Get Object ETag:\n {0}\n", GetResult2.ETag);

            System.Console.WriteLine("HeadObject!\n");
            GetObjectMetadataRequest request4 = new GetObjectMetadataRequest();
            request4.WithBucketName(bucketName);
            request4.WithKey(objectName2);
            DateTime datetime2 = DateTime.UtcNow;
            // 似乎不支援 datetime
            request4.WithModifiedSinceDate(datetime2.AddHours(-1));
            request4.WithUnmodifiedSinceDate(datetime2.AddHours(1));
            request4.WithETagToMatch(PutResult2.ETag);
            request4.WithETagToNotMatch("notMatch");
            GetObjectMetadataResponse HeadResult2 = s3Client.GetObjectMetadata(request4);
            System.Console.WriteLine("HeadObject: (1)ContentLength: {0} (2)ETag: {1}\n", HeadResult2.ContentLength, HeadResult2.ETag);

            CopyObjectRequest request5 = new CopyObjectRequest();
            request5.WithSourceBucket(bucketName);
            request5.WithSourceKey(objectName2);
            request5.WithDestinationBucket(bucketName);
            request5.WithDestinationKey("hihi2");
            DateTime datetime3 = DateTime.UtcNow;
            // 似乎不支援 datetime
            request5.WithModifiedSinceDate(datetime3.AddHours(-1));
            request5.WithUnmodifiedSinceDate(datetime3.AddHours(1));
            request5.WithETagToMatch(PutResult2.ETag);
            request5.WithETagToNotMatch("notMatch");
            request5.WithMetaData(nvc);
            request5.WithCannedACL(S3CannedACL.PublicRead);
            request5.WithContentType("test/xml");
            request5.WithWebsiteRedirectLocation("http://hicloud.hinet.net/");
            CopyObjectResponse CopyResult2 = s3Client.CopyObject(request5);
            System.Console.WriteLine("CopyObject: ETag: {0} \n", CopyResult2.ETag);

            System.Console.WriteLine("Delete Object!\n");
            s3Client.DeleteObject(new DeleteObjectRequest().WithBucketName(bucketName).WithKey(objectName2));
            s3Client.DeleteObject(new DeleteObjectRequest().WithBucketName(bucketName).WithKey("hihi2")); //copied object
            //==============================jerry add end==============================

            //DeleteBucket
            System.Console.WriteLine("Delete Bucket!\n");
            //s3Client.DeletesBucket(new DeleteBucketRequest().WithBucketName(bucketName));
            s3Client.DeleteBucket(new DeleteBucketRequest().WithBucketName(bucketName));
            System.Console.WriteLine("END!");
        }
Exemple #11
0
        public String Save(DirectoryEnum denum, String localFilename)
        {
            String directory = getDirectory(denum);
            if (_storageMode == StorageMode.S3)
            {
                PutObjectRequest request = new PutObjectRequest();
                request.WithBucketName("FaceSpace");
                String s3path = directory + _directorySeparator + Path.GetFileName(localFilename);
                request.WithKey(s3path);
                request.WithFilePath(localFilename);
                request.AutoCloseStream = true;
                request.CannedACL = S3CannedACL.PublicRead;

                AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(_accessKey, _secretKey, RegionEndpoint.USEast1);
                //var client = Amazon.AWSClientFactory.CreateAmazonS3Client(RegionEndpoint.USEast1);
                using (S3Response r = client.PutObject(request)) { }
                return "https://s3.amazonaws.com/FaceSpace/" + s3path;
            }
            else
            {
                String dest = _localPath + "\\" + directory + _directorySeparator + Path.GetFileName(localFilename);
                System.IO.File.Copy(localFilename, dest, true);
                return _virtualDirectory + "\\" + directory + _directorySeparator + Path.GetFileName(localFilename);
            }
        }