diff options
author | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-22 17:22:43 +0100 |
---|---|---|
committer | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-22 17:22:43 +0100 |
commit | a50da4215c88efcdcab1da2835459b64a5b341b4 (patch) | |
tree | d99f45ab6416906ac0954e0d3b8f90b860264cbd /files.go |
Initial Commit
Diffstat (limited to 'files.go')
-rw-r--r-- | files.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/files.go b/files.go new file mode 100644 index 0000000..f1a3d6c --- /dev/null +++ b/files.go @@ -0,0 +1,23 @@ +package main + +import ( + "encoding/base64" + "io/ioutil" +) + +func writeFile(postcache PostCache, filename string) error { + data := postcache.Data + var binary []byte + + n, err := base64.StdEncoding.Decode(binary, []byte(data)) + if n == 0 || err != nil { + return err + } + + err = ioutil.WriteFile("files/"+filename, binary, 0644) + if err != nil { + return err + } + + return nil +} |