public async Task Create(Guid id, Stream fileStream, string fileName) { NoSQLFile p = new NoSQLFile(); p.Content = new byte[fileStream.Length]; await fileStream.ReadAsync(p.Content); p.Name = fileName; p.BaseEntityGuid = id; await Create(p); }
public async Task StoreDirect() { string filePath = @"d:\tests\"; string fileName = "HelloWorld.docx"; using (var fileStream = new FileStream(filePath + fileName, FileMode.Open)) { NoSQLFile p = new NoSQLFile(); p.Content = new byte[fileStream.Length]; await fileStream.ReadAsync(p.Content); fileStream.Close(); p.Name = fileName; p.BaseEntityGuid = Guid.NewGuid(); await Create(p); } }
private async Task<IActionResult> CreateFile(IFormFile uploadedFile, Guid? flowId = null) { Guid _flowId = flowId == null ? new Guid() : (Guid)flowId; if (uploadedFile != null) { byte[] content = await uploadedFile.GetBytes(); NoSQLFile p = new NoSQLFile(); p.Content = new byte[content.Length]; content.CopyTo(p.Content, 0); p.Name = uploadedFile.FileName; p.BaseEntityGuid = _flowId; await _fileService.Create(p); return Ok(p.Id); } return BadRequest("File was not transferred!"); }
public async Task Update(NoSQLFile p) { await _files.ReplaceOneAsync(new BsonDocument("_id", new ObjectId(p.Id)), p); }
public async Task Create(NoSQLFile p) { await _files.InsertOneAsync(p); }