public void CreateImageOnlyWithQueue() { var newGuid = Guid.NewGuid(); var image = new Image { Created = DateTime.Now, Description = "Test description", id = newGuid, Name = "Test name", // use our fluffy test image Bytes = File.ReadAllBytes("Images/dog-medium-landing-hero.jpg") }; DocumentDbHelper.AddImageToDbAsync( image ).Wait(); Console.WriteLine($"{newGuid} written to database!"); ServiceBusHelper .AddMessageToQueueAsync($"{image.id}") .Wait(); Console.WriteLine($"{newGuid} written to service bus!"); }
public void TestDocumentDbWrangling() { var newGuid = Guid.NewGuid(); var image = new Image { Created = DateTime.Now, Description = "Test description", id = newGuid, Name = "Test name", // use our fluffy test image Bytes = File.ReadAllBytes("Images/dog-medium-landing-hero.jpg") }; Console.WriteLine($"{newGuid} written to database!"); DocumentDbHelper.AddImageToDbAsync( image ).Wait(); // get the image back var imageBack = DocumentDbHelper .GetImageAsync($"{newGuid}") .Result; imageBack.Created = DateTime.Now; imageBack.IllegalWatermark = true; // Run the custom vision service //CustomerVisionHelper // .RunCustomVisionService(imageBack); // can we call out to cognitive services? VisionApiHelper .AdornImageWithVisionMetadataAsync(imageBack); // change date and update the image DocumentDbHelper .UpdateImage(imageBack); // delete the image // get the image back DocumentDbHelper .DeleteImageAsync($"{newGuid}").Wait(); }
public async Task UploadSingleFile() { var bytes = await Request .Content .ReadAsByteArrayAsync(); var guid = Guid.NewGuid(); await DocumentDbHelper.AddImageToDbAsync(new Core.Class.Image { id = guid, Bytes = bytes }); await ServiceBusHelper .AddMessageToQueueAsync(guid.ToString() ); }