Exemplo n.º 1
0
        public virtual async Task <MediaDescriptorDto> CreateAsync(CreateMediaInputStream inputStream)
        {
            var newId     = GuidGenerator.Create();
            var stream    = inputStream.GetStream();
            var newEntity = new MediaDescriptor(newId, inputStream.Name, inputStream.ContentType, stream.Length, CurrentTenant.Id);

            await MediaContainer.SaveAsync(newId.ToString(), stream);

            await MediaDescriptorRepository.InsertAsync(newEntity);

            return(ObjectMapper.Map <MediaDescriptor, MediaDescriptorDto>(newEntity));
        }
Exemplo n.º 2
0
        public virtual async Task <IActionResult> UploadAsync(IFormFile file)
        {
            if (file == null)
            {
                return(BadRequest());
            }

            var inputStream = new CreateMediaInputStream(file.OpenReadStream())
            {
                ContentType = file.ContentType,
                Name        = file.FileName
            };

            var mediaDescriptorDto = await MediaDescriptorAdminAppService.CreateAsync(inputStream);

            return(StatusCode((int)HttpStatusCode.Created, mediaDescriptorDto));
        }
Exemplo n.º 3
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));
            }
        }
 public virtual Task <MediaDescriptorDto> CreateAsync(CreateMediaInputStream inputStream)
 {
     return(MediaDescriptorAdminAppService.CreateAsync(inputStream));
 }