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



##########
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:
       Concerning this PR, I think uploading a small file without partSize 
should be enough. We cover createMultipartUploadRequest, createMultipartUpload, 
uploadPart and completeMultipartUpload.
   
   Concerning follow up issues to improve camel-aw2-s3 component. Checking 
partSize >= 5MB is a good idea, ideally the 5MB value should come from amazon 
in case it changes. Concerning the chunk-signature, indeed maybe camel-aws2-s3 
should strip it and set a header or something.




-- 
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