-
Notifications
You must be signed in to change notification settings - Fork 50
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
Missing Presigned POST / POST Policy support for multipart form-data file uploads #809
Comments
Hi @Somnium99, thanks for reaching out. If you're looking to pre-sign PutObject requests, the AWS SDK for Kotlin provides an extension method on the request object: val s3 = ... // An already-configured S3 client
val putRequest = PutObjectRequest {
bucket = "issmith-test-bucket-us-west-2"
key = "foo"
}
val presignedPutRequest = putReq.presign(s3.config, 1.days) The returned object is an For example, to send a presigned PutObject request with OkHttp: val client = OkHttpClient()
val textPlainMediaType = "text/plain".toMediaType()
val objectContents = "Foo text!"
val okRequest = Request
.Builder()
.url(presignedPutRequest.url.toString())
.put(objectContents.toRequestBody(textPlainMediaType))
.build()
val okResponse = client.newCall(okRequest).execute() The POST (multipart/form-data) upload variant of PutObject is intended for use in browsers specifically. The SDK does not provide a mechanism to generate a signed POST request for browsers. Does that answer your question? |
Hi @ianbotsf , thank you for the response I want to generate in our Server presigned urls for our clients (browsers + mobile platforms(Android + iOS)), so the clients could upload the file by parts, using form-data (POST) multipart. However, The current To support POST Policy, there needs to be something that: And of course an option to add uploadId + partNumber for presigning the parts individually , and not just one big file. Perhaps it's not a fix, but rather a new feature to support POST Policy. Thank you |
To clarify, the GH link you posted talks about multipart S3 uploads. That is the process of completing a object upload across multiple API calls (e.g., The AWS SDK for Kotlin does not yet have a mechanism to create multipart-encoded requests that could be used to construct web forms for submission by a browser. We'd like to add this feature in the future but at this time you must construct the necessary form fields yourself (including signing whatever policy is attached). I'll leave this issue open for tracking and we'll update it when the work is complete. |
I'll put this here for anyone looking for this feature: |
Describe the feature
For Pre-signed multipart form-data uploads, one must use POST (PUT is for binary data).
Therefore AWS introduced the POST Policy.
Is your Feature Request related to a problem?
It's impossible to use multipart form-data uploads in this sdk.
Proposed Solution
UploadPartRequest
should also include support for POST, and not do always PUT internally.To support POST Policy, there needs to be something that:
Describe alternative solutions or features you've considered
No response
Acknowledge
AWS Kotlin SDK version used
v0.19.2-beta
Platform (JVM/JS/Native)
JVM
Operating System and version
MacOS
The text was updated successfully, but these errors were encountered: