moved bucket name to env variable

This commit is contained in:
Jonathan Barrow 2022-01-04 08:38:26 -05:00
parent 9e76d1218f
commit 2f429fe7bc
5 changed files with 11 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"os"
nex "github.com/PretendoNetwork/nex-go"
nexproto "github.com/PretendoNetwork/nex-protocols-go"
@ -12,7 +13,7 @@ func completeAttachFile(err error, client *nex.Client, callID uint32, dataStoreC
// TODO: complete this
rmcResponseStream.WriteString(fmt.Sprintf("http://pds-amaj-d1.b-cdn.net/image/%d.jpg", dataStoreCompletePostParam.DataID))
rmcResponseStream.WriteString(fmt.Sprintf("http://%s.b-cdn.net/image/%d.jpg", os.Getenv("DO_SPACES_NAME"), dataStoreCompletePostParam.DataID))
rmcResponseBody := rmcResponseStream.Bytes()

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"os"
nex "github.com/PretendoNetwork/nex-go"
nexproto "github.com/PretendoNetwork/nex-protocols-go"
@ -16,7 +17,7 @@ func getObjectInfos(err error, client *nex.Client, callID uint32, dataIDs []uint
info := nexproto.NewDataStoreFileServerObjectInfo()
info.DataID = courseMetadata.DataID
info.GetInfo = nexproto.NewDataStoreReqGetInfo()
info.GetInfo.URL = fmt.Sprintf("http://pds-AMAJ-d1.b-cdn.net/course/%d.bin", courseMetadata.DataID)
info.GetInfo.URL = fmt.Sprintf("http://%s.b-cdn.net/course/%d.bin", os.Getenv("DO_SPACES_NAME"), courseMetadata.DataID)
info.GetInfo.RequestHeaders = []*nexproto.DataStoreKeyValue{}
info.GetInfo.Size = courseMetadata.Size
info.GetInfo.RootCA = []byte{}

View File

@ -15,7 +15,7 @@ import (
func prepareAttachFile(err error, client *nex.Client, callID uint32, dataStoreAttachFileParam *nexproto.DataStoreAttachFileParam) {
key := fmt.Sprintf("image/%d.jpg", dataStoreAttachFileParam.ReferDataID)
bucket := "pds-amaj-d1"
bucket := os.Getenv("DO_SPACES_NAME")
date := strconv.Itoa(int(time.Now().Unix()))
pid := strconv.Itoa(int(client.PID()))

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"os"
nex "github.com/PretendoNetwork/nex-go"
nexproto "github.com/PretendoNetwork/nex-protocols-go"
@ -11,15 +12,16 @@ func prepareGetObject(err error, client *nex.Client, callID uint32, dataStorePre
pReqGetInfo := nexproto.NewDataStoreReqGetInfo()
if dataStorePrepareGetParam.DataID == 900000 {
pReqGetInfo.URL = "http://pds-AMAJ-d1.b-cdn.net/special/900000.bin"
pReqGetInfo.URL = fmt.Sprintf("http://%s.b-cdn.net/special/900000.bin", os.Getenv("DO_SPACES_NAME"))
pReqGetInfo.RequestHeaders = []*nexproto.DataStoreKeyValue{}
pReqGetInfo.Size = 450068
//pReqGetInfo.Size = 450068
pReqGetInfo.Size = 0x263C
pReqGetInfo.RootCA = []byte{}
pReqGetInfo.DataID = 900000
} else {
courseMetadata := getCourseMetadataByDataID(dataStorePrepareGetParam.DataID)
pReqGetInfo.URL = fmt.Sprintf("http://pds-AMAJ-d1.b-cdn.net/course/%d.bin", dataStorePrepareGetParam.DataID)
pReqGetInfo.URL = fmt.Sprintf("http://%s.b-cdn.net/course/%d.bin", os.Getenv("DO_SPACES_NAME"), dataStorePrepareGetParam.DataID)
pReqGetInfo.RequestHeaders = []*nexproto.DataStoreKeyValue{}
pReqGetInfo.Size = courseMetadata.Size
pReqGetInfo.RootCA = []byte{}

View File

@ -29,7 +29,7 @@ func preparePostObject(err error, client *nex.Client, callID uint32, param *nexp
}
key := fmt.Sprintf("course/%d.bin", dataID)
bucket := "pds-amaj-d1"
bucket := os.Getenv("DO_SPACES_NAME")
date := strconv.Itoa(int(time.Now().Unix()))
pid := strconv.Itoa(int(client.PID()))