Example #1
0
        private async Task <(string location, int width, int height)> ResizeAndUploadPhotoAsync(byte[] photoBytes, int desiredWidth, string key)
        {
            await _semaphore.WaitAsync();

            try
            {
                var sw = Stopwatch.StartNew();
                var(width, height, data) = ResizeImage(photoBytes, desiredWidth);
                var resizeTime = (int)sw.ElapsedMilliseconds;
                var location   = await _photosRepository.PutPublicItemAsync(key, data);

                _logger.LogInformation($"Resize of image {key} took {resizeTime} ms");
                return(location, width, height);
            }
            finally
            {
                _semaphore.Release();
            }
        }