feat: add originals and thumbnails folder for pictures

This commit is contained in:
Yanislav Igonin 2021-09-12 11:31:43 +03:00
parent 6838a2ded4
commit b2b2fc3268
4 changed files with 16 additions and 3 deletions

View File

@ -151,6 +151,7 @@ func CreateThread(c *gin.Context) {
path := filepath.Join( path := filepath.Join(
Utils.UPLOADS_DIR_PATH, Utils.UPLOADS_DIR_PATH,
strconv.Itoa(postID), strconv.Itoa(postID),
"o",
strconv.Itoa(fileID)+"."+file.Ext, strconv.Itoa(fileID)+"."+file.Ext,
) )
err = c.SaveUploadedFile(fileInRequest, path) err = c.SaveUploadedFile(fileInRequest, path)
@ -247,6 +248,7 @@ func UpdateThread(c *gin.Context) {
path := filepath.Join( path := filepath.Join(
Utils.UPLOADS_DIR_PATH, Utils.UPLOADS_DIR_PATH,
strconv.Itoa(threadID), strconv.Itoa(threadID),
"o",
strconv.Itoa(fileID)+"."+file.Ext, strconv.Itoa(fileID)+"."+file.Ext,
) )
err = c.SaveUploadedFile(fileInRequest, path) err = c.SaveUploadedFile(fileInRequest, path)

View File

@ -24,7 +24,7 @@
{{ if gt $length 0 }} {{ if gt $length 0 }}
{{ $FirstFile := index $Post.Files 0 }} {{ $FirstFile := index $Post.Files 0 }}
<img <img
src="/uploads/{{$Post.ID}}/{{$FirstFile.ID}}.{{$FirstFile.Ext}}" src="/uploads/{{$Post.ID}}/o/{{$FirstFile.ID}}.{{$FirstFile.Ext}}"
class="card-img-top" class="card-img-top"
alt="Uploaded picture" alt="Uploaded picture"
> >

View File

@ -31,9 +31,9 @@
<div class="files-container"> <div class="files-container">
{{ range $File := $Post.Files }} {{ range $File := $Post.Files }}
<div class="file-container"> <div class="file-container">
<a href="/uploads/{{$FirstPost.ID}}/{{$File.ID}}.{{$File.Ext}}" target="blank"> <a href="/uploads/{{$FirstPost.ID}}/o/{{$File.ID}}.{{$File.Ext}}" target="blank">
<img <img
src="/uploads/{{$FirstPost.ID}}/{{$File.ID}}.{{$File.Ext}}" src="/uploads/{{$FirstPost.ID}}/o/{{$File.ID}}.{{$File.Ext}}"
class="file" class="file"
alt="Uploaded picture" alt="Uploaded picture"
> >

View File

@ -44,6 +44,17 @@ func CreateThreadFolder(postID int) error {
return err return err
} }
originalsFolder := filepath.Join(threadDirPath, "o")
err = os.Mkdir(originalsFolder, 0755)
if err != nil {
return err
}
thumbnailsFolder := filepath.Join(threadDirPath, "t")
err = os.Mkdir(thumbnailsFolder, 0755)
if err != nil {
return err
}
return nil return nil
} }