Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add POST to transparent S3 api #26

wants to merge 3 commits into from

Conversation

uberspot
Copy link
Collaborator

@uberspot uberspot commented Feb 3, 2022

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.

Signed-off-by: Pawel Sarbinowski <[email protected]>
Signed-off-by: Pawel Sarbinowski <[email protected]>

resp, err := s3Client.CreateMultipartUpload(input)
if err != nil {
fmt.Println(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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, "")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants