private Settings()
        {
            FirstTime = false;

            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                System.Deployment.Application.ApplicationDeployment cd =
                    System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
                Version = cd.CurrentVersion.ToString();
            }
            else
            {
                Version = DevelopmentVersion;
            }
            _appVersionFolder = KnownFolders.GetAppVersionFolder(Version);
            //DbCache = new DbCache(AppVersionFolder + "\\ms.video.downloader.settings.sqlite");
            _configuration = GetApplicationConfiguration();

            if (_configuration != null)
            {
                _fileSystem = new S3FileSystem(_configuration.S3AccessKey, _configuration.S3SecretAccessKey, _configuration.S3RegionHost, _configuration.S3BucketName);
                return;
            }
            FirstTime      = true;
            _configuration = new ApplicationConfiguration {
                Guid = Guid.NewGuid(), S3IsActive = false
            };
            SetApplicationConfiguration(_configuration);
            _fileSystem = new S3FileSystem(_configuration.S3AccessKey, _configuration.S3SecretAccessKey, _configuration.S3RegionHost, _configuration.S3BucketName);
        }
Пример #2
0
        public void SetUp()
        {
            var file1 = new Mock <IFileInfoWrap>();

            file1.Setup(x => x.Name).Returns("File1.jpg");
            file1.Setup(x => x.FullName).Returns("c:\\files\\File1.jpg");

            var file2 = new Mock <IFileInfoWrap>();

            file2.Setup(x => x.Name).Returns("File2.jpg");
            file2.Setup(x => x.FullName).Returns("c:\\files\\File2.jpg");

            var file3 = new Mock <IFileInfoWrap>();

            file3.Setup(x => x.Name).Returns("File3.jpg");
            file3.Setup(x => x.FullName).Returns("c:\\files\\morefiles\\File3.jpg");

            var file4 = new Mock <IFileInfoWrap>();

            file4.Setup(x => x.Name).Returns("File4.jpg");
            file4.Setup(x => x.FullName).Returns("c:\\files\\morefiles\\File4.jpg");

            var file5 = new Mock <IFileInfoWrap>();

            file5.Setup(x => x.Name).Returns("File5.jpg");
            file5.Setup(x => x.FullName).Returns("c:\\files\\otherfiles\\File5.jpg");

            var moreFilesDirectory = new Mock <IDirectoryInfoWrap>();

            moreFilesDirectory.Setup(x => x.GetFiles()).Returns(() => new IFileInfoWrap[] { file3.Object, file4.Object });
            moreFilesDirectory.Setup(x => x.GetDirectories()).Returns(() => new IDirectoryInfoWrap[] { });
            moreFilesDirectory.Setup(x => x.Exists).Returns(() => true);
            moreFilesDirectory.Setup(x => x.Name).Returns(() => "morefiles");
            moreFilesDirectory.Setup(x => x.FullName).Returns(() => "c:\\files\\morefiles");

            var otherfilesDirectory = new Mock <IDirectoryInfoWrap>();

            otherfilesDirectory.Setup(x => x.GetFiles()).Returns(() => new IFileInfoWrap[] { file5.Object });
            otherfilesDirectory.Setup(x => x.GetDirectories()).Returns(() => new IDirectoryInfoWrap[] { });
            otherfilesDirectory.Setup(x => x.Exists).Returns(() => true);
            otherfilesDirectory.Setup(x => x.Name).Returns(() => "otherfiles");
            otherfilesDirectory.Setup(x => x.FullName).Returns(() => "c:\\files\\otherfiles");

            DirectoryInfo = new Mock <IDirectoryInfoWrap>();
            DirectoryInfo.Setup(x => x.GetFiles()).Returns(() => new IFileInfoWrap[] { file1.Object, file2.Object });
            DirectoryInfo.Setup(x => x.GetDirectories()).Returns(() => new IDirectoryInfoWrap[] { moreFilesDirectory.Object, otherfilesDirectory.Object });
            DirectoryInfo.Setup(x => x.Exists).Returns(() => true);
            DirectoryInfo.Setup(x => x.Name).Returns(() => "files");
            DirectoryInfo.Setup(x => x.FullName).Returns(() => "c:\\files");

            var notFoundException = new AmazonS3Exception("Key not found", HttpStatusCode.NotFound);

            AmazonS3 = new Mock <AmazonS3>();
            AmazonS3.Setup(x => x.PutObject(It.IsAny <PutObjectRequest>())).Returns(new PutObjectResponse()).Verifiable();
            AmazonS3.Setup(x => x.GetObjectMetadata(It.IsAny <GetObjectMetadataRequest>())).Throws(notFoundException);

            S3FileSystem = new S3FileSystem(AmazonS3.Object, GetFileStreamFromFile);
        }
Пример #3
0
 protected override void ProcessRecord()
 {
     try
     {
         var logger = new PsCmdletLogger(this);
         s3FileSystem = new S3FileSystem(logger, AccessKey, Secret, new AmazonS3Config());
         s3FileSystem.UploadFiles(new DirectoryInfoWrap(Folder), Recurse, Bucket, SetPublicRead);
     }
     catch (Exception e)
     {
         ThrowTerminatingError(
             new ErrorRecord(
                 e,
                 "Copy-FilesToS3",
                 ErrorCategory.NotSpecified,
                 this
                 )
             );
     }
 }
Пример #4
0
 public S3PhotoBackupService(string bucketName = "")
 {
     _fileSystem = new S3FileSystem(bucketName);
 }
Пример #5
0
 public void TearDown()
 {
     S3FileSystem  = null;
     DirectoryInfo = null;
     AmazonS3      = null;
 }
Пример #6
0
 protected override void EndProcessing()
 {
     s3FileSystem = null;
 }
 public S3PhotoBackupService(string bucketName="")
 {
     _fileSystem = new S3FileSystem(bucketName);
 }
 public void UpdateConfiguration()
 {
     SetApplicationConfiguration(_configuration);
     _fileSystem = new S3FileSystem(_configuration.S3AccessKey, _configuration.S3SecretAccessKey, _configuration.S3RegionHost, _configuration.S3BucketName);
 }