title: Base64 string decode and save as file
body: <p>This has been doing my head in and I hope someone can help. Please forgive me if it's a stupid question as I am very new to Go.</p>
  
  <p>I have a struct that has base64 in it. the struct looks like this:</p>
  
  <pre><code> type UploadedFile struct {
      PartnerId string
      FileName string
      UploadDateTime string
      FileChecksum string
      FileBase64 string
   }
  </code></pre>
  
  <p>I want to take that base64 string, decode it and then save it, sounds simple right and it probably is, but I am struck.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>decoder := json.NewDecoder(r.Body)
  uploadedFile := models.UploadedFile{}
  err := decoder.Decode(&amp;uploadedFile)
  dec, _ := base64.StdEncoding.DecodeString(uploadedFile.FileBase64)
  </code></pre>
  
  <p>Where do I go from here? I have tried so many things and I just keep getting errors all over the file.</p>
  
  <p>I have tried adapting code that people use for images, but I always crash and burn as the file isn't an image, it could be anything</p>
  
  <p>Thanks in advance.</p>