From 2f429fe7bc60fbc71c812e223eaf3d56de39a14f Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Tue, 4 Jan 2022 08:38:26 -0500 Subject: [PATCH] moved bucket name to env variable --- complete_attach_file.go | 3 ++- get_object_infos.go | 3 ++- prepare_attach_file.go | 2 +- prepare_get_object.go | 8 +++++--- prepare_post_object.go | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/complete_attach_file.go b/complete_attach_file.go index 194b7da..2e1bc1c 100644 --- a/complete_attach_file.go +++ b/complete_attach_file.go @@ -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() diff --git a/get_object_infos.go b/get_object_infos.go index fdc2b5a..33b2917 100644 --- a/get_object_infos.go +++ b/get_object_infos.go @@ -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{} diff --git a/prepare_attach_file.go b/prepare_attach_file.go index 3fcda84..1cb7176 100644 --- a/prepare_attach_file.go +++ b/prepare_attach_file.go @@ -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())) diff --git a/prepare_get_object.go b/prepare_get_object.go index 3412240..47a4eb5 100644 --- a/prepare_get_object.go +++ b/prepare_get_object.go @@ -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{} diff --git a/prepare_post_object.go b/prepare_post_object.go index b999e3f..77b9959 100644 --- a/prepare_post_object.go +++ b/prepare_post_object.go @@ -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()))