zhfeng commented on a change in pull request #3077:
URL: https://github.com/apache/camel-quarkus/pull/3077#discussion_r705864789



##########
File path: 
integration-test-groups/aws2/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/Aws2S3Resource.java
##########
@@ -97,18 +123,152 @@ public Response read(@PathParam("key") String key) throws 
Exception {
     @Path("s3/object-keys")
     @GET
     @Produces(MediaType.APPLICATION_JSON)
-    public List<String> objectKey() throws Exception {
+    public List<String> objectKey(@QueryParam("bucket") String bucket) throws 
Exception {
+        if (bucket == null) {
+            bucket = bucketName;
+        }
+
         final List<S3Object> objects = (List<S3Object>) 
producerTemplate.requestBody(
-                componentUri(AWS2S3Operations.listObjects),
+                componentUri(bucket, AWS2S3Operations.listObjects) + 
"&autoCreateBucket=true",
                 null,
                 List.class);
         return 
objects.stream().map(S3Object::key).collect(Collectors.toList());
     }
 
-    private String componentUri(final AWS2S3Operations operation) {
+    @Path("s3/upload")
+    @POST
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String multipartUpload(@MultipartForm MultipartFormDataInput input) 
throws Exception {
+
+        Map<String, List<InputPart>> formDataMap = input.getFormDataMap();
+        String fileName = formDataMap.get("fileName").get(0).getBodyAsString();
+
+        if (fileName == null) {
+            throw new FileNotFoundException();
+        }
+
+        File file = File.createTempFile("aws2-", ".tmp");
+
+        List<InputPart> inputParts = formDataMap.get("file");
+        for (InputPart inputPart : inputParts) {
+            InputStream inputStream = inputPart.getBody(InputStream.class, 
null);
+            Files.copy(inputStream, file.toPath(), 
StandardCopyOption.REPLACE_EXISTING);

Review comment:
       Acoording to 
https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html
   ```
   Each part must be at least 5 MB in size, except the last part. There is no 
size limit on the last part of your multipart upload.
   ```
   
   I think we should add this limit in the camel-aws2-s3 document.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to