Exemplo n.º 1
0
        private AssetMetadata StoreMetadata(AssetStorageMetadata storageMetadata)
        {
            var assetMetadata = new AssetMetadata
            {
                Id              = Id,
                Name            = Name,
                Description     = Description,
                ContentType     = WebFile.ContentType,
                Url             = storageMetadata.StorageLocation,
                StorageMetadata = storageMetadata,
                Type            = AssetTypeMapping.GetTypeFor(WebFile.ContentType)
            };

            _assetDocumentRepository.Create(assetMetadata);

            return(assetMetadata);
        }
Exemplo n.º 2
0
        private static void UploadAsset(FileMetadata file)
        {
            var assetFileRepository     = new ImageFileRepository();
            var assetDocumentRepository = new AssetDocumentRepository();
            var notifier = new MessageBusClient();

            var assetRootPath = ConfigurationManager.AppSettings["ImageRootPath"];

            var id           = Guid.NewGuid().ToString();
            var fileInfo     = FileReader.GetFileInfo(file.FileLocation);
            var fileContents = FileReader.ReadFile(file.FileLocation);
            var fileName     = $"original{fileInfo.Extension}";


            var storageMetadata = assetFileRepository.StoreAsset(id, fileName, "image/jpeg", fileContents);

            if (storageMetadata == null)
            {
                return;
            }

            var imageMetadata    = FileReader.GetImageMetadata(file.FileName);
            var imageDescription = imageMetadata.GetValue("Exif IFD0", "Image Description");


            var assetMetadata = new AssetMetadata
            {
                Id              = id,
                Name            = file.FileName,
                Description     = imageDescription ?? string.Empty,
                Category        = file.Category,
                ContentType     = "image/jpeg",
                Author          = file.Photographer,
                Url             = $"{assetRootPath}/{storageMetadata.StorageId}",
                StorageMetadata = storageMetadata,
                Type            = "image"
            };

            assetDocumentRepository.Create(assetMetadata);

            notifier.SendMessage(new NewImageAdded {
                ImageName = storageMetadata.StorageId, Id = id
            });
        }
Exemplo n.º 3
0
 public void Create(AssetMetadata metadata)
 {
     _repository.Create(metadata);
 }