public static async Task Process(Stream image, CloudBlockBlob jsonBlob, string name, TraceWriter log)
        {
            log.Info($"[CognitiveServices] - Triggered for image name: {name}, size: {image.Length} bytes");

            try
            {
                image.Position = 0;
                image.Seek(0, SeekOrigin.Begin);

                var data = await GetCognitiveServicesData(image);

                var json = JsonConvert.SerializeObject(data);

                await JsonBlobUploader.UploadBlob(jsonBlob, json);

                log.Info($"[CognitiveServices] - Analysis completed for {name}. File location: {jsonBlob.Uri.AbsoluteUri}");
            }
            catch (Exception exception)
            {
                log.Error($"[CognitiveServices] - Failed: {exception.Message}", exception);
            }
        }
Esempio n. 2
0
        public static async Task Process(Stream image, CloudBlockBlob jsonBlob, string name, TraceWriter log)
        {
            log.Info($"[Exif] - Triggered for image name: {name}, size: {image.Length} bytes");

            try
            {
                if (NoExifData(image))
                {
                    log.Error("[Exif] - No EXIF data present");
                    await JsonBlobUploader.UploadBlob(jsonBlob, EmptyJsonString);

                    return;
                }

                if (UnsupportedFileType(image))
                {
                    log.Error("[Exif] - Only jpg-files supported for EXIF-data");
                    await JsonBlobUploader.UploadBlob(jsonBlob, EmptyJsonString);

                    return;
                }

                image.Position = 0;

                var data = GetExifData(image);
                var json = JsonConvert.SerializeObject(data);

                await JsonBlobUploader.UploadBlob(jsonBlob, json);

                log.Info($"[Exif] - EXIF-extraction completed for {name}. File location: {jsonBlob.Uri.AbsoluteUri}");
            }
            catch (Exception exception)
            {
                log.Error($"[Exif] - Failed: {exception.Message}", exception);
            }
        }