public File Create(Guid userId, string fileName, string contentType, int contentLength, System.IO.Stream fileStream) { User user = _userRepository.FindById(userId); string path = string.Format("{0}/{1}", DateTime.UtcNow.Ticks, fileName); var file = new File { User = user, Path = path, ContentLength = contentLength, ContentType = contentType, FileType = GetFileType(contentType), Identifier = 1 }; file = _fileRepository.Create(file); _azureFileService.SaveFile(user.UserName, path, fileStream); if (file.FileType.FileTypeEnum == FileTypeEnum.Image) { CreateThumbnail(file, fileStream); } return(file); }
private void CreateThumbnail(File file, System.IO.Stream fileStream) { const int thumbnailWidth = 1300; using (Stream thumbnailStream = ImageHelper.GetThumbnail(fileStream, thumbnailWidth)) { string thumbnailPath = string.Format("thumbnails/{0}", file.Path); thumbnailStream.Seek(0, SeekOrigin.Begin); _azureFileService.SaveFile(file.User.UserName, thumbnailPath, thumbnailStream); } }
public string GetUrlToFileThumbnail(File file) { return(_azureFileService.GetUrlToFileThumbnail(file.User.UserName, file.Path)); }