예제 #1
0
        public virtual async Task <MediaDescriptorDto> CreateAsync(string entityType, CreateMediaInputWithStream inputStream)
        {
            var definition = await MediaDescriptorDefinitionStore.GetAsync(entityType);

            /* TODO: Shouldn't CreatePolicies be a dictionary and we check for inputStream.EntityType? */
            await CheckAnyOfPoliciesAsync(definition.CreatePolicies);

            var newEntity = await MediaDescriptorManager.CreateAsync(entityType, inputStream.Name, inputStream.File.ContentType, inputStream.File.ContentLength ?? 0);

            await MediaContainer.SaveAsync(newEntity.Id.ToString(), inputStream.File.GetStream());

            await MediaDescriptorRepository.InsertAsync(newEntity);

            return(ObjectMapper.Map <MediaDescriptor, MediaDescriptorDto>(newEntity));
        }
예제 #2
0
        public virtual async Task <MediaDescriptorDto> CreateAsync(CreateMediaInputStream inputStream)
        {
            var definition = await MediaDescriptorDefinitionStore.GetDefinitionAsync(inputStream.EntityType);

            await CheckAnyOfPoliciesAsync(definition.CreatePolicies);

            using (var stream = inputStream.GetStream())
            {
                var newEntity = await MediaDescriptorManager.CreateAsync(inputStream.EntityType, inputStream.Name, inputStream.ContentType, inputStream.ContentLength ?? 0);

                await MediaContainer.SaveAsync(newEntity.Id.ToString(), stream);

                await MediaDescriptorRepository.InsertAsync(newEntity);

                return(ObjectMapper.Map <MediaDescriptor, MediaDescriptorDto>(newEntity));
            }
        }