public async Task<HttpResponseMessage> Post(FileModel model) { var userFile = new DomainUserFile { Created = DateTime.UtcNow, Modified = DateTime.UtcNow, UserId = UserId, FileUri = model.File.Uri, ContentType = model.File.ContentType, FileLength = model.File.Length, FileName = model.Name }; userFile = await _userFileRepository.AddAsync(userFile); var file = new File { ContentType = userFile.ContentType, Name = userFile.FileName, Uri = userFile.FileUri, Id = userFile.FileId, Length = userFile.FileLength }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, file); response.SetLastModifiedDate(userFile.Modified); return response; }
// // GET /api/files/{id} /// <summary> /// Receives file by identifier. /// </summary> /// <param name="id">Identifier.</param> /// <returns>File.</returns> public async Task<HttpResponseMessage> Get([FromUri] string id) { var userFile = new DomainUserFile { UserId = UserId, FileId = id }; userFile = await _userFileRepository.GetAsync(userFile); var file = new File { ContentType = userFile.ContentType, Name = userFile.FileName, Uri = userFile.FileUri, Id = userFile.FileId, Length = userFile.FileLength }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, file); response.SetLastModifiedDate(userFile.Modified); return response; }