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



##########
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:
       Not an expert too, trying to sort it out :) From the readings, please 
find a proposal below:
   - The test send a simple string content and a key to this method (so we 
don't use @ MultipartForm)
   - The string content is put in a `aws2-*.tmp` temp file
   - We send this temp file and key with `multiPartUpload=true`
   - Optionally, we try to make AWS2 library to chunk the content with low 
partSize for instance `partSize=1`
   
   Would such a test makes sense ?




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