file 경로에서 servicecode 제거

This commit is contained in:
2023-08-22 18:06:14 +09:00
parent bafb67dabc
commit e3afb58634

View File

@ -2,9 +2,7 @@ package core
import ( import (
"bytes" "bytes"
"crypto/md5"
"encoding/binary" "encoding/binary"
"encoding/hex"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -109,10 +107,6 @@ var seq = uint32(0)
func (caller apiCaller) uploadAPI(w http.ResponseWriter, r *http.Request) error { func (caller apiCaller) uploadAPI(w http.ResponseWriter, r *http.Request) error {
if r.Method == "PUT" { if r.Method == "PUT" {
hasher := md5.New()
hasher.Write(caller.mg.service().serviceCodeBytes)
subfolder := hex.EncodeToString(hasher.Sum(nil))[:8]
infile, header, err := r.FormFile("file") infile, header, err := r.FormFile("file")
if err != nil { if err != nil {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -128,17 +122,16 @@ func (caller apiCaller) uploadAPI(w http.ResponseWriter, r *http.Request) error
var b [5]byte var b [5]byte
binary.BigEndian.PutUint32(b[0:4], uint32(time.Now().Unix())) binary.BigEndian.PutUint32(b[0:4], uint32(time.Now().Unix()))
b[4] = byte(atomic.AddUint32(&seq, 1) % 255) b[4] = byte(atomic.AddUint32(&seq, 1) % 255)
rf := hex.EncodeToString(b[1:])
newidstr := subfolder + rf
newidbt, _ := hex.DecodeString(newidstr)
newidobj := primitive.NewObjectID()
copy(newidobj[:], newidbt[:8])
newidobj := primitive.NewObjectID()
copy(newidobj[:], b[1:])
rf := newidobj.Hex()
var link string var link string
if extract { if extract {
link = path.Join("static", subfolder, rf) link = path.Join("static", rf)
} else { } else {
link = path.Join("static", subfolder, rf, header.Filename) link = path.Join("static", rf, header.Filename)
} }
newdoc := FileDocumentDesc{ newdoc := FileDocumentDesc{