Skip to content

Commit

Permalink
Add timestamp to asset image name
Browse files Browse the repository at this point in the history
  • Loading branch information
wjuniorbh92 committed Jan 10, 2024
1 parent 7742474 commit cfbf581
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/internal/usecase/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package usecase
import (
"fmt"
"strconv"
"time"

"github.com/CheesecakeLabs/token-factory-v2/backend/config"
"github.com/CheesecakeLabs/token-factory-v2/backend/internal/entity"
Expand Down Expand Up @@ -87,7 +88,9 @@ func (uc *AssetUseCase) GetAll() ([]entity.Asset, error) {
}

func (uc *AssetUseCase) UploadImage(data entity.Asset, imageBytes []byte) error {
s3Name := fmt.Sprint(data.Code, "_", data.Issuer.Key.PublicKey)
timestamp := time.Now().Format("20060102_150405")
s3Name := fmt.Sprintf("%s_%s_%s", data.Code, data.Issuer.Key.PublicKey, timestamp)

assetImage, err := uc.storageService.UploadFile(s3Name, imageBytes)
if err != nil {
return fmt.Errorf("AssetUseCase - Create - uc.awsService.UploadAssetImage: %w", err)
Expand Down

0 comments on commit cfbf581

Please sign in to comment.