From 8e2ab34ba0f673e1adde950edf1b333849959207 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Wed, 23 Jan 2019 20:18:18 -0800 Subject: [PATCH] Fix remaining issues with S3 backend --- backends/s3/s3.go | 23 +++++++++++------------ fileserve.go | 4 ---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/backends/s3/s3.go b/backends/s3/s3.go index 831bf05..b453747 100644 --- a/backends/s3/s3.go +++ b/backends/s3/s3.go @@ -4,7 +4,6 @@ import ( "io" "io/ioutil" "os" - "path" "strconv" "time" @@ -32,7 +31,7 @@ func (b S3Backend) Delete(key string) error { if err != nil { return err } - return os.Remove(path.Join(b.bucket, key)) + return nil } func (b S3Backend) Exists(key string) (bool, error) { @@ -75,29 +74,29 @@ func (b S3Backend) Get(key string) (metadata backends.Metadata, r io.ReadCloser, func mapMetadata(m backends.Metadata) map[string]*string { return map[string]*string{ - "expiry": aws.String(strconv.FormatInt(m.Expiry.Unix(), 10)), - "delete_key": aws.String(m.DeleteKey), - "size": aws.String(strconv.FormatInt(m.Size, 10)), - "mimetype": aws.String(m.Mimetype), - "sha256sum": aws.String(m.Sha256sum), + "Expiry": aws.String(strconv.FormatInt(m.Expiry.Unix(), 10)), + "Delete_key": aws.String(m.DeleteKey), + "Size": aws.String(strconv.FormatInt(m.Size, 10)), + "Mimetype": aws.String(m.Mimetype), + "Sha256sum": aws.String(m.Sha256sum), } } func unmapMetadata(input map[string]*string) (m backends.Metadata, err error) { - expiry, err := strconv.ParseInt(*input["expiry"], 10, 64) + expiry, err := strconv.ParseInt(aws.StringValue(input["Expiry"]), 10, 64) if err != nil { return } m.Expiry = time.Unix(expiry, 0) - m.Size, err = strconv.ParseInt(*input["size"], 10, 64) + m.Size, err = strconv.ParseInt(aws.StringValue(input["Size"]), 10, 64) if err != nil { return } - m.DeleteKey = *input["delete_key"] - m.Mimetype = *input["mimetype"] - m.Sha256sum = *input["sha256sum"] + m.DeleteKey = aws.StringValue(input["Delete_key"]) + m.Mimetype = aws.StringValue(input["Mimetype"]) + m.Sha256sum = aws.StringValue(input["Sha256sum"]) return } diff --git a/fileserve.go b/fileserve.go index 30a5de6..3066b79 100644 --- a/fileserve.go +++ b/fileserve.go @@ -50,10 +50,6 @@ func fileServeHandler(c web.C, w http.ResponseWriter, r *http.Request) { w.Header().Set("Etag", metadata.Sha256sum) w.Header().Set("Cache-Control", "max-age=0") - // TODO: implement If-Match, If-None-Match (ETag) - // TODO: implement If-Unmodified-Since, If-Modified-Since (Last-Modified) - // TODO: implement range requests? - if r.Method != "HEAD" { defer reader.Close()