use the ID for the document filenames
This commit is contained in:
parent
9a25bc406f
commit
e5748ec8d5
2 changed files with 6 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
|||
ViewData["Title"] = $"Viewing \"{Model.Document.Title}\"";
|
||||
ViewData["SlimNavbar"] = true;
|
||||
ViewData["NoMainPadding"] = true;
|
||||
string path = $"/Content/{Model.Document.ID}.pdf";
|
||||
}
|
||||
|
||||
<iframe id="document-viewer" src="/Content/@Model.Document.Filename"></iframe>
|
||||
<iframe id="document-viewer" src="@path"></iframe>
|
|
@ -32,10 +32,10 @@ namespace Snootalogue.Pages {
|
|||
return Page();
|
||||
}
|
||||
|
||||
var filename = WebUtility.HtmlEncode(ud.UploadedFile.FileName);
|
||||
var id = Document.NewID(_context);
|
||||
// var uploadDirectory = Path.Combine(filename);
|
||||
var uploadDirectory = "wwwroot/Content";
|
||||
var destination = Path.Combine(uploadDirectory, filename);
|
||||
var destination = Path.Combine(uploadDirectory, $"{id}.pdf");
|
||||
|
||||
using (var fs = new FileStream(destination, FileMode.Create)) {
|
||||
await ud.UploadedFile.CopyToAsync(fs);
|
||||
|
@ -43,14 +43,14 @@ namespace Snootalogue.Pages {
|
|||
|
||||
// Document d = _context.Document.
|
||||
Document d = new Document {
|
||||
ID = Document.NewID(_context),
|
||||
ID = id,
|
||||
Title = ud.Title,
|
||||
Authors = ud.Authors.Split(",").ToList<string>(),
|
||||
Category = ud.Category,
|
||||
Tags = string.IsNullOrWhiteSpace(ud.Tags) ? null : ud.Tags.Split(",").ToList<string>(),
|
||||
Notes = ud.Notes,
|
||||
Read = ud.Read,
|
||||
Filename = filename
|
||||
Filename = WebUtility.HtmlEncode(ud.UploadedFile.FileName)
|
||||
};
|
||||
|
||||
_context.Document.Add(d);
|
||||
|
|
Loading…
Reference in a new issue