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["Title"] = $"Viewing \"{Model.Document.Title}\"";
|
||||||
ViewData["SlimNavbar"] = true;
|
ViewData["SlimNavbar"] = true;
|
||||||
ViewData["NoMainPadding"] = 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();
|
return Page();
|
||||||
}
|
}
|
||||||
|
|
||||||
var filename = WebUtility.HtmlEncode(ud.UploadedFile.FileName);
|
var id = Document.NewID(_context);
|
||||||
// var uploadDirectory = Path.Combine(filename);
|
// var uploadDirectory = Path.Combine(filename);
|
||||||
var uploadDirectory = "wwwroot/Content";
|
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)) {
|
using (var fs = new FileStream(destination, FileMode.Create)) {
|
||||||
await ud.UploadedFile.CopyToAsync(fs);
|
await ud.UploadedFile.CopyToAsync(fs);
|
||||||
|
@ -43,14 +43,14 @@ namespace Snootalogue.Pages {
|
||||||
|
|
||||||
// Document d = _context.Document.
|
// Document d = _context.Document.
|
||||||
Document d = new Document {
|
Document d = new Document {
|
||||||
ID = Document.NewID(_context),
|
ID = id,
|
||||||
Title = ud.Title,
|
Title = ud.Title,
|
||||||
Authors = ud.Authors.Split(",").ToList<string>(),
|
Authors = ud.Authors.Split(",").ToList<string>(),
|
||||||
Category = ud.Category,
|
Category = ud.Category,
|
||||||
Tags = string.IsNullOrWhiteSpace(ud.Tags) ? null : ud.Tags.Split(",").ToList<string>(),
|
Tags = string.IsNullOrWhiteSpace(ud.Tags) ? null : ud.Tags.Split(",").ToList<string>(),
|
||||||
Notes = ud.Notes,
|
Notes = ud.Notes,
|
||||||
Read = ud.Read,
|
Read = ud.Read,
|
||||||
Filename = filename
|
Filename = WebUtility.HtmlEncode(ud.UploadedFile.FileName)
|
||||||
};
|
};
|
||||||
|
|
||||||
_context.Document.Add(d);
|
_context.Document.Add(d);
|
||||||
|
|
Loading…
Reference in a new issue