Beispiel #1
0
        public async Task <CipherResponseModel> PostAttachment(string id)
        {
            ValidateAttachment();

            var idGuid = new Guid(id);
            var userId = _userService.GetProperUserId(User).Value;
            var cipher = await _cipherRepository.GetByIdAsync(idGuid, userId);

            if (cipher == null)
            {
                throw new NotFoundException();
            }

            await Request.GetFileAsync(async (stream, fileName) =>
            {
                await _cipherService.CreateAttachmentAsync(cipher, stream, fileName,
                                                           Request.ContentLength.GetValueOrDefault(0), userId);
            });

            return(new CipherResponseModel(cipher, _globalSettings));
        }