file 경로에서 servicecode 제거
This commit is contained in:
19
core/api.go
19
core/api.go
@ -2,9 +2,7 @@ package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -109,10 +107,6 @@ var seq = uint32(0)
|
||||
|
||||
func (caller apiCaller) uploadAPI(w http.ResponseWriter, r *http.Request) error {
|
||||
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")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
@ -128,17 +122,16 @@ func (caller apiCaller) uploadAPI(w http.ResponseWriter, r *http.Request) error
|
||||
var b [5]byte
|
||||
binary.BigEndian.PutUint32(b[0:4], uint32(time.Now().Unix()))
|
||||
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
|
||||
if extract {
|
||||
link = path.Join("static", subfolder, rf)
|
||||
link = path.Join("static", rf)
|
||||
} else {
|
||||
link = path.Join("static", subfolder, rf, header.Filename)
|
||||
link = path.Join("static", rf, header.Filename)
|
||||
}
|
||||
|
||||
newdoc := FileDocumentDesc{
|
||||
|
||||
Reference in New Issue
Block a user