From c2bb85adfdc402b99c16f0a9e474769609160bed Mon Sep 17 00:00:00 2001
From: Pawel Sarbinowski
Date: Thu, 3 Feb 2022 17:52:09 +0000
Subject: [PATCH 1/3] Add POST to transparent S3 api
Signed-off-by: Pawel Sarbinowski
---
main.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/main.go b/main.go
index 012e8e6..79f870f 100644
--- a/main.go
+++ b/main.go
@@ -174,6 +174,7 @@ func runServer() {
})
router.GET("/:bucket/*key", transparentS3Get)
router.PUT("/:bucket/*key", transparentS3Put)
+ router.POST("/:bucket/*key", transparentS3Put)
router.DELETE("/:bucket/*key", transparentS3Delete)
}
From 2224827576c01176785788a92afc64c176a0de75 Mon Sep 17 00:00:00 2001
From: Pawel Sarbinowski
Date: Fri, 4 Feb 2022 09:03:25 +0000
Subject: [PATCH 2/3] Bump version
Signed-off-by: Pawel Sarbinowski
---
main.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.go b/main.go
index 79f870f..441ab6e 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
From 085f9e89d32244b3f0b1950d3bce02b423220354 Mon Sep 17 00:00:00 2001
From: Pawel Sarbinowski
Date: Fri, 4 Feb 2022 16:25:11 +0000
Subject: [PATCH 3/3] Change approach to post multi-part uploads
Signed-off-by: Pawel Sarbinowski
---
main.go | 2 +-
s3.go | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/main.go b/main.go
index 441ab6e..83e2049 100644
--- a/main.go
+++ b/main.go
@@ -174,7 +174,7 @@ func runServer() {
})
router.GET("/:bucket/*key", transparentS3Get)
router.PUT("/:bucket/*key", transparentS3Put)
- router.POST("/: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")