Example #1
0
        public ExceptionController(IBlobHandler blobHandler,
                                   IOptions <BlobOptions> settings)
        {
            _blobHandler = blobHandler ??
                           throw new ArgumentNullException(nameof(blobHandler));

            _options = settings.Value;
        }
Example #2
0
 /// <summary>
 /// Main Controller
 /// </summary>
 /// <param name="userProfile">User Service</param>
 /// <param name="blobRepo">Blob Repository</param>
 public AzureBlobStorageController(IUserProfileService userProfile,
                                   IBlobStorageRepository blobRepo,
                                   IOptionsSnapshot <IoTHubOptions> iotOptions,
                                   IOptionsSnapshot <BlobOptions> blobOptions,
                                   IOptionsSnapshot <CosmosDbOptions> cosmostOptions,
                                   ILogger <AzureBlobStorageController> logger)
     : base(userProfile)
 {
     _blobRepo           = blobRepo;
     this.logger         = logger;
     this.cosmostOptions = cosmostOptions.Value;
     this.iotOptions     = iotOptions.Value;
     this.blobOptions    = blobOptions.Value;
 }
        public FaceController(IFaceHandler faceHandler,
                              IBlobHandler blobHandler,
                              IEventHandler eventHandler,
                              IOptions <BlobOptions> settings)
        {
            _faceHandler = faceHandler ??
                           throw new ArgumentNullException(nameof(faceHandler));

            _blobHandler = blobHandler ??
                           throw new ArgumentNullException(nameof(blobHandler));

            _eventhandler = eventHandler ??
                            throw new ArgumentNullException(nameof(eventHandler));

            _options = settings.Value;
        }
        private async Task UploadBlobAsync(string blobName, Object obj, IDictionary <string, string> metadata = null)
        {
            BlobOptions         config          = blobOptions.Value;
            BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(config.ContainerName);
            BlobClient          blobClient      = containerClient.GetBlobClient(blobName);

            await using (var ms = new MemoryStream())
            {
                LoadStreamWithJson(obj, ms);
                await blobClient.UploadAsync(ms, new BlobHttpHeaders { ContentType = ContentType });
            }

            if (metadata != null && metadata.Count > 0)
            {
                await blobClient.SetMetadataAsync(metadata);
            }
        }
        public async Task UploadLocalFileShouldSucceed()
        {
            blobDataManager = new BlobDataManager();
            var options = new BlobOptions
            {
                BlobName = "testBlob",
                BlobType = BlobType.BlockBlob,
                ConnectionString = ConnectionString,
                ContainerName = ContainerName,
                OverwriteDestination = true,
                Public = true
            };

            await blobDataManager.UploadFileToBlobAsync("SampleData.txt", options);

            Assert.True(blobDataManager.ProgressRecorder.LatestNumberOfFilesFailed == 0);
            Assert.True(blobDataManager.ProgressRecorder.LatestNumberOfFilesTransferred == 1);
        }
        public async Task UploadLocalFileShouldSucceed()
        {
            blobDataManager = new BlobDataManager();
            var options = new BlobOptions
            {
                BlobName             = "testBlob",
                BlobType             = BlobType.BlockBlob,
                ConnectionString     = ConnectionString,
                ContainerName        = ContainerName,
                OverwriteDestination = true,
                Public = true
            };

            await blobDataManager.UploadFileToBlobAsync("SampleData.txt", options);

            Assert.True(blobDataManager.ProgressRecorder.LatestNumberOfFilesFailed == 0);
            Assert.True(blobDataManager.ProgressRecorder.LatestNumberOfFilesTransferred == 1);
        }