-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add POST to transparent S3 api #26
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to set the context before returning, like |
||||||
} | ||||||
log.Debugf("Response: ", resp) | ||||||
c.XML(200, resp) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It depends on what the multipart POST expects as a response, either you need a new XML struct in https://github.com/MarshallWace/cachenator/blob/master/s3_structs.go or a plain response like for transparent put |
||||||
//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") | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key and bucket need empty string checks