aboutsummaryrefslogtreecommitdiff
path: root/files.go
diff options
context:
space:
mode:
Diffstat (limited to 'files.go')
-rw-r--r--files.go23
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
+}