public void TestUploadDownloadAndDeleteBlob()
        {
            var fakeLogger      = A.Fake <ILogger>();
            var fakeAppSettings = new NodeAppSettingsOptions
            {
                AzureBlobStoreConnectionString = "DefaultEndpointsProtocol=https;AccountName=storage4bc24aff;AccountKey=v+6FRH8H3xFOlLoHaRzLsrdeFtKRoTrSC+Y/dAoE2W48054GHwXQ4LDRgl2tWonforFjOagmuPK2Ei4E45/r9g==;EndpointSuffix=core.windows.net",
                AzureBlobContainerReference    = "test-datastoreblobs"
            };
            var fakeAppSettingsOptions = Options.Create(fakeAppSettings);

            var sut = new AzureBlobStore(fakeLogger, fakeAppSettingsOptions);

            sut.Connect();

            var filePath    = Path.Combine(TestContext.CurrentContext.WorkDirectory, "TestData\\test1.jpg");
            var fileStream  = File.OpenRead(filePath);
            var fakeBlobRef = $"fakeBlobRef";

            sut.UploadFile(fakeBlobRef, fileStream);

            Assert.That(sut.FileExists(fakeBlobRef), Is.True);

            var downloadedFileStream = (MemoryStream)sut.DownloadFile(fakeBlobRef);
            var downloadedFileBytes  = downloadedFileStream.ToArray();

            Assert.That(downloadedFileBytes.Length, Is.EqualTo(3941897));

            sut.DeleteFile(fakeBlobRef);

            Assert.That(sut.FileExists(fakeBlobRef), Is.False);
        }
Beispiel #2
0
        public BlockchainDBRepository(
            ILogger logger,
            IAggregateState <ItemMetadata> aggregateState,
            IOptions <NodeAppSettingsOptions> nodeAppSettingsOptions,
            IOptions <NodeP2PSettingsOptions> nodeP2POptions,
            IAzureBlobStore azureBlobStore
            )
        {
            _logger = logger;
            _nodeAppSettingsOptions = nodeAppSettingsOptions.Value;

            _aggregateState = aggregateState;
            _aggregateState.PersistChain = true;

            _azureBlobStore = azureBlobStore;
            _azureBlobStore.Connect();

            var nodeAddress = new NodeAddress("127.0.0.1", nodeP2POptions.Value.Port);
            var addressList = new List <NodeAddress>();

            _p2PNode = new Node(nodeAddress, addressList);

            // wire up P2P behaviours
            _aggregateState.WireUpNode(_p2PNode);

            // setup indices
            _aggregateState.AddIndex(BlobRef_Idx, (item) => item.BlobRef);
            _aggregateState.AddIndex(Metadata_Name_Idx, (item) => item.Name);
            _aggregateState.AddIndex(Metadata_Value_Idx, (item) => item.Value);

            _aggregateState.InitialiseChainFromBlobs();
        }
 public AuthController(
     IUserManager userManager,
     IOptions <NodeAppSettingsOptions> appSettingsOptions)
 {
     _userManager        = userManager;
     _appSettingsOptions = appSettingsOptions.Value;
 }
 public AzureBlobStore(
     ILogger logger,
     IOptions <NodeAppSettingsOptions> nodeAppSettingsOptions
     )
 {
     _logger = logger;
     _nodeAppSettingsOptions = nodeAppSettingsOptions.Value;
 }
 public FilesController(
     ILogger logger,
     ITempFileHelper tempFileHelper,
     IDataRepository dataRepository,
     IFileTypeScanner fileTypeScanner,
     IFileVirusScanner fileVirusScanner,
     IFileHasher fileHasher,
     IHttpContextAccessor httpContextAccessor,
     IOptions <NodeAppSettingsOptions> appSettingsOptions)
 {
     _logger              = logger;
     _tempFileHelper      = tempFileHelper;
     _dataRepository      = dataRepository;
     _fileTypeScanner     = fileTypeScanner;
     _fileVirusScanner    = fileVirusScanner;
     _fileHasher          = fileHasher;
     _httpContextAccessor = httpContextAccessor;
     _appSettingsOptions  = appSettingsOptions.Value;
 }