title: The specified method is not allowed against this resource in Amazon aws
body: <p>Guys I may or may not be wrong, But seriously, I am struggling with file uploading problem in Amazon S3 bucket. When I am trying to hit on the request then I am getting the following error. </p>
  
  <blockquote>
    <p><strong>MethodNotAllowed</strong> and <strong>The specified method is not allowed against this resource</strong></p>
  </blockquote>
  
  <p>The above message is the sort of the below response. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;Error&gt;&lt;Code&gt;MethodNotAllowed&lt;/Code
  &lt;Message&gt;Thespecified method is not allowed against this resource.&lt;/Message&gt;
  &lt;Method&gt;POST&lt;/Method&gt;&lt;ResourceType&gt;OBJECT&lt;/ResourceType&gt;
  &lt;RequestId&gt;xxx&lt;/RequestId&gt;&lt;HostId&gt;xxxx&lt;/HostId&gt;&lt;/Error&gt;
  </code></pre>
  
  <p>The above message is the complete message and below is the code whatever I have written for uploading files to amazon s3 server. </p>
  
  <pre><code>public synchronized boolean uploadFile(String url, String name, File file) {
      HttpEntity entity = MultipartEntityBuilder.create()
              .addPart("file", new FileBody(file)).build();
      HttpPost request = new HttpPost(url);
      request.setEntity(entity);
      HttpClient client = HttpClientBuilder.create().build();
      try {
          HttpResponse response = client.execute(request);
          entity = response.getEntity();
          if (entity != null) {
              try (InputStream in_stream = entity.getContent()) {
                  BufferedReader in = new BufferedReader(new InputStreamReader(in_stream));
                  String inputLine;
                  StringBuilder responseBuffer = new StringBuilder();
                  while ((inputLine = in.readLine()) != null) {
                      responseBuffer.append(inputLine);
                  }
                  in.close();
                  String a = responseBuffer.toString();
                  Utils.print("\n\n" + a + "\n\n");
              }
          }
          return true;
      } catch (Exception e) {
          Utils.print(e);
      }
      return false;
  }
  </code></pre>
  
  <p>Please suggest me what to do for this? I will be very thankful for your expected answer. </p>