Skip to content

Commit

Permalink
保存先ディレクトリを年度で指定
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubosaka committed Jan 22, 2025
1 parent ceeb5c3 commit a97df2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/externals/repository/object_upload_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"log"
"mime/multipart"
"strconv"
"time"

"github.com/NUTFes/FinanSu/api/drivers/mc"
minio "github.com/minio/minio-go/v7"
Expand All @@ -23,8 +25,9 @@ func NewObjectUploadRepository(c mc.Client) ObjectUploadRepository {

// 画像をアップロード
func (or *objectUploadRepository) UploadFile(c context.Context, file *multipart.FileHeader) error {
currentYear := strconv.Itoa(time.Now().Year())
size := file.Size
fileName := "/2024/receipts/" + file.Filename
fileName := "/" + currentYear + "/receipts/" + file.Filename
openFile, err := file.Open()
if err != nil {
log.Println(err)
Expand Down
6 changes: 6 additions & 0 deletions api/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package main

import (
"time"

"github.com/NUTFes/FinanSu/api/internals/di"
_ "github.com/go-sql-driver/mysql"
)

func main() {
// JSTに設定
time.Local = time.FixedZone("JST", 9*60*60)
time.LoadLocation("JST")

client := di.InitializeServer()
defer client.CloseDB()
}

0 comments on commit a97df2e

Please sign in to comment.