diff --git a/main.go b/main.go index 012e8e6..83e2049 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ import ( log "github.com/sirupsen/logrus" ) -const version string = "0.17.3" +const version string = "0.17.4" var ( host string @@ -174,6 +174,7 @@ func runServer() { }) router.GET("/:bucket/*key", transparentS3Get) router.PUT("/:bucket/*key", transparentS3Put) + router.POST("/:bucket/*key", transparentS3Post) router.DELETE("/:bucket/*key", transparentS3Delete) } diff --git a/s3.go b/s3.go index fddae01..568f98b 100644 --- a/s3.go +++ b/s3.go @@ -9,6 +9,8 @@ import ( "fmt" "strings" "sync" + + //"net/http" "time" "github.com/adrianchifor/go-parallel" @@ -180,6 +182,35 @@ func transparentS3Put(c *gin.Context) { c.String(200, "") } +func transparentS3Post(c *gin.Context) { + bucket := c.Param("bucket") + key := c.Param("key") + //file := c.Param("file") + uploads, ok := c.Get("uploads") + log.Debugf("Upload Params:", uploads) + if !ok { + log.Debugf("Uploads Param exists, starting new multi-part post upload") + input := &s3.CreateMultipartUploadInput{ + Bucket: aws.String(bucket), + Key: aws.String(key), + //ContentType: aws.String(fileType), + } + + resp, err := s3Client.CreateMultipartUpload(input) + if err != nil { + fmt.Println(err.Error()) + return + } + log.Debugf("Response: ", resp) + c.XML(200, resp) + //c.Data(http.StatusOK, "text/html; charset=utf-8", []byte(resp.String())) + + } + + log.Debugf("Uploads %s request started '%s#%s' from S3", uploads, bucket, key) + +} + func transparentS3Get(c *gin.Context) { bucket := c.Param("bucket") key := c.Param("key")