-
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?
Conversation
Signed-off-by: Pawel Sarbinowski <[email protected]>
011325f
to
c2bb85a
Compare
Signed-off-by: Pawel Sarbinowski <[email protected]>
f18caf4
to
2224827
Compare
Signed-off-by: Pawel Sarbinowski <[email protected]>
d4ff0dd
to
085f9e8
Compare
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Println(err.Error()) | |
log.Errorf("Failed to create multipart upload: %v", err) |
@@ -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") |
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
resp, err := s3Client.CreateMultipartUpload(input) | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return |
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.
You need to set the context before returning, like c.String(500, "")
return | ||
} | ||
log.Debugf("Response: ", resp) | ||
c.XML(200, resp) |
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.
resp
is a go struct, not XML https://docs.aws.amazon.com/sdk-for-go/api/service/s3/#CreateMultipartUploadOutput
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.String(200, "")
The following example initiates a multipart upload by sending an HTTP POST request to the URI of the multipart-uploads
Seems to be part of the S3 api spec according to:
https://aws.amazon.com/premiumsupport/knowledge-center/s3-multipart-upload-cli/
and
https://github.com/apoorvam/aws-s3-multipart-upload/blob/master/aws-multipart-upload.go
But I'm not 100% confident how this will handle non-multi-part uploads too.