Beispiel #1
0
        static void TestGetConfig()
        {
            BlobStorageConfig config = BlobStorageConfig.GetConfig("C:/Users/t-chwang/source/repos/ImageServingPlatform/Core/config.json");

            Console.WriteLine(config.StorageConnectionStringFile);
            Console.WriteLine(config.StorageConnectionString);
        }
Beispiel #2
0
        public static BlobStorageConfig GetConfig(String configJsonFile)
        {
            String            jsonStr = File.ReadAllText(configJsonFile);
            BlobStorageConfig config  = JsonConvert.DeserializeObject <BlobStorageConfig>(jsonStr);
            String            storageConnectionStringFileStr = File.ReadAllText(config.StorageConnectionStringFile);

            config.StorageConnectionString =
                JObject.Parse(storageConnectionStringFileStr)["StorageConnectionString"].ToString();
            return(config);
        }
Beispiel #3
0
        static void TestUploadBlob()
        {
            BlobStorageConfig config      = BlobStorageConfig.GetConfig("C:/Users/t-chwang/source/repos/ImageServingPlatform/Core/config.json");
            BlobStorage       blobStorage = new BlobStorage(config);
            FileStream        fs          = new FileStream("C:/Users/t-chwang/source/repos/ImageServingPlatform/Core/Resource/testpic/github-octocat.png", FileMode.Open);

            Task <Uri> t = blobStorage.UploadAsync(fs, "abc.png");

            t.Wait();
            Console.WriteLine(t.Result);
        }
        public ImageService(BlobStorageConfig config, ImageProcessor imageProcessor,
                            IStorage storage, IDBManager <Image> dBManager)
        {
            this.config         = config;
            this.imageProcessor = imageProcessor;
            this.storage        = storage;
            this.dbManager      = dBManager;

            ILoggerFactory loggerFactory = new LoggerFactory()
                                           .AddConsole();

            ILogger logger = loggerFactory.CreateLogger <ImageService>();
        }
Beispiel #5
0
        static async void TestUploadBinaryAsync()
        {
            BlobStorageConfig config         = BlobStorageConfig.GetConfig("C:/Users/t-chwang/source/repos/ImageServingPlatform/Core/config.json");
            BlobStorage       blobStorage    = new BlobStorage(config);
            ImageProcessor    imageProcessor = new ImageProcessor();
            ImageDBManager    imageDBManager = new ImageDBManager(new MediaRecordDatabaseContext());

            ImageService imageService = new ImageService(config, imageProcessor, blobStorage, imageDBManager);

            FileStream fs = new FileStream("C:/Users/t-chwang/source/repos/ImageServingPlatform/Core/Resource/testpic/github-octocat.png", FileMode.Open);

            byte[] fileContent = new BinaryReader(fs).ReadBytes((int)fs.Length);
            Console.WriteLine(fileContent.Length);
            fs.Close();

            await imageService.UploadBinaryAsync(fileContent, "abc.png");

            Console.WriteLine("End of TestUploadBinaryAsync. ");
        }