public async Task PostFileForExistingAttachment(string id, string attachmentId) { if (!Request?.ContentType.Contains("multipart/") ?? true) { throw new BadRequestException("Invalid content."); } if (!_globalSettings.SelfHosted) { throw new BadRequestException("Invalid endpoint for non self-hosted servers."); } var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId); var attachments = cipher?.GetAttachments(); if (attachments == null || !attachments.ContainsKey(attachmentId)) { throw new NotFoundException(); } var attachmentData = attachments[attachmentId]; await Request.GetFileAsync(async (stream) => { await _cipherService.UploadFileForExistingAttachmentAsync(stream, cipher, attachmentData); }); }