public async Task<SavedFile> Assemble(FileAssemblyRequest item)
        {
            SavedFile savedFileInformation = await ChunkedFileStorageService.AssembleFileFromBlocksAsync(item);

			//todo, get file information back from save call
			byte[] fileContents = ChunkedFileStorageService.RetrieveFileContents(savedFileInformation);

			ExtractedImageInformation exInfo = new ExtractedImageInformation();
			exInfo.File = savedFileInformation;

            InformationExtractor extractor = new InformationExtractor();
			exInfo = extractor.GetImageInformation(savedFileInformation, fileContents, exInfo);

			//generate thumbnail
			byte[] thumbnailBytes = new ThumbnailGenerator().GenerateThumbnail(fileContents);
			exInfo.Preview = ChunkedFileStorageService.SaveFileWithoutChunking(savedFileInformation.UploadedFileName, "thumbnail", thumbnailBytes);

            //write to raven
            StoredImage info = Mapper.Map<StoredImage>(exInfo);
            info.UploadDateTime = DateTime.Now;
            await RavenSession.StoreAsync(info);

            //signal the hub that we are done
            var context = GlobalHost.ConnectionManager.GetHubContext<PictureProcessHub>();
            context.Clients.All.pictureprocessed(Mapper.Map<ProcessedImageViewModel>(info));

            return savedFileInformation;
        }
Exemplo n.º 2
0
        public ExtractedImageInformation GetImageInformation(SavedFile savedFileInformation, byte[] fileContents, ExtractedImageInformation info)
        {
            //TODO, I Should be a parallel async call

            info = new TaglibExtractor().ExtractTags(savedFileInformation.StorageFileName, fileContents, info);
            if (string.IsNullOrWhiteSpace(info.Title))
            {
                info.Title = MakeTitleFromFileName(savedFileInformation.UploadedFileName);
            }

            return info;
        }
Exemplo n.º 3
0
 public ExtractedImageInformation ExtractTags(string sourcePath, byte[] sourceArray, ExtractedImageInformation info)
 {
     using (var file = new MemoryStreamFileAbstraction(sourcePath, sourceArray))
     {
         using (var imageFile = TagLib.File.Create(file) as TagLib.Image.File)
         {
             info.Orientation = (int)imageFile.ImageTag.Orientation;
             info.Latitude = imageFile.ImageTag.Latitude;
             info.Longitude = imageFile.ImageTag.Latitude;
             info.Timestamp = imageFile.ImageTag.DateTime;
             info.Title = imageFile.ImageTag.Title;
             return info;
         }
     }
 }