title: Upload zip file or image to Amazon s3 using java and html input form
body: <p>Hope you can help me out. I couldn't find any answers to my question</p>
  
  <p>I've got this part of JSP code:</p>
  
  <pre><code>  &lt;html:form action="/restricted/gallery/GalleryUpload" method="post" enctype="multipart/form-data"&gt;  
    &lt;table width="98%" border="0" cellspacing="0" cellpadding="2"&gt;
      &lt;tr&gt;
        &lt;td width="21%" align="right" class="input_head"&gt;Upload Image: &amp;nbsp;&lt;/td&gt;
        &lt;td class="size12_text_red"&gt;&lt;html:file property="file" styleId="File"/&gt;&amp;nbsp;&lt;br/&gt;(Contents of zip files will be extracted and uploaded individually)&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr align="center"&gt;
        &lt;td colspan="4"&gt;&lt;input name="upload2" type="submit" id="upload" class="butt_style" value="Submit"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p></p>
  
  <p>Then I i'm passing the data through to the Java class:</p>
  
  <pre><code>            else if (req.getParameter("upload2") != null) {
  
              String existingBucketName = "BUCKETNAME";           
              String filePath = cform.getFile().toString(); 
              String keyName = filePath.substring(filePath.lastIndexOf("/")+1); 
  
              String amazonFileUploadLocationOriginal=existingBucketName+"/gallery/"+user.getOwnerId()+"/album_name"; 
              AmazonS3 s3Client = new AmazonS3Client(new PropertiesCredentials(SouthdownsServicesAction.class.getResourceAsStream("AwsCredentials.properties"))); 
              FileInputStream stream = new FileInputStream(filePath); 
              ObjectMetadata objectMetadata = new ObjectMetadata(); 
              PutObjectRequest putObjectRequest = new PutObjectRequest(amazonFileUploadLocationOriginal, keyName, stream, objectMetadata); 
              PutObjectResult result = s3Client.putObject(putObjectRequest); 
  </code></pre>
  
  <p>So what i'm trying to do is, in the filePath section i'm trying to pass the full path from the input form file you've selected to there but it simply doesn't work. If i change that filePath to a simple path located on my local machine it works fine. Like the following:</p>
  
  <pre><code>String filePath = "C://Pics//logo.jpg"; 
  </code></pre>
  
  <p>Then if i upload a ZIP file instead of an image how will it extract the ZIP content and upload all files individually?</p>
  
  <p>Thanks in advance</p>