title: Amazon s3 bucket path issue
body: <p>I am new to amazons3 i want to upload a file to s3 bucket. So i am writing a code in java for that but I don't how to specify the path of the bucket. Can any one help me in that.
  PLease help in finding a solution for getting the correct path of the s3 bucket.</p>
  
  <pre><code>public class SampleS3 {
  
      private static final String SUFFIX = "/";
      private static String existingBucketName = "s3-buckt path";
      private static String AccessKey = "accesskey";
      private static String SecretAccessKey = "SecretAccessKey";
      private static String keyName = "mypic.JPG";
      private static String filePath = "/home/dll files/samplefile.txt";
      private static String amazonFileUploadLocationOriginal = existingBucketName+ "/";
  
  
      public static void main(String[] args) throws IOException {
  
          executeUpload();
      }
  
      private static void executeUpload() {
  
          AWSCredentials credentials = new BasicAWSCredentials(AccessKey,
                  SecretAccessKey);
  
          AmazonS3 s3Client = new AmazonS3Client(credentials);
          String folderName = "testfolder";
          createFolder(existingBucketName, folderName, s3Client);
          String fileName = folderName + SUFFIX + "testvideo.mp4";
          s3Client.putObject(new PutObjectRequest(existingBucketName, fileName,
                  new File(filePath))
                  .withCannedAcl(CannedAccessControlList.PublicRead));
      }
  
      public static void createFolder(String bucketName, String folderName,
              AmazonS3 client) {
          ObjectMetadata metadata = new ObjectMetadata();
          metadata.setContentLength(0);
          InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
          PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName,
                  folderName + SUFFIX, emptyContent, metadata);
          client.putObject(putObjectRequest);
      }
  
  }
  </code></pre>
  
  <p>When I run the program i get error as:</p>
  
  <pre><code>Exception in thread "main" com.amazonaws.services.s3.model.AmazonS3Exception: The specified bucket does not exist (Service: Amazon S3; Status Code: 404; Error Code: NoSuchBucket; Request ID: 2D45010A48E44C42), S3 Extended Request ID: c7zzSgYO8bNUh9HoOVVmAbjjtG7G6w5tQmuSIqTmgf3cGqjclTrJS3WIXvPpV7Mt
      at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1389)
      at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:902)
      at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)
      at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)
      at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)
      at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)
      at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3826)
      at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1405)
      at com.qagate.s3.amazons3.SampleS3.createFolder(SampleS3.java:65)
      at com.qagate.s3.amazons3.SampleS3.executeUpload(SampleS3.java:45)
      at com.qagate.s3.amazons3.SampleS3.main(SampleS3.java:33)
  </code></pre>