code: private void setAcl(String bucketName, String key, String versionId, AccessControlList acl, boolean isRequesterPays,
              AmazonWebServiceRequest originalRequest) {
          if (originalRequest == null) originalRequest = new GenericBucketRequest(bucketName);
  
          Request<AmazonWebServiceRequest> request = createRequest(bucketName, key, originalRequest, HttpMethodName.PUT);
  
          if (bucketName != null && key != null) {
              request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "PutObjectAcl");
          } else if (bucketName != null) {
              request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "PutBucketAcl");
          }
  
          request.addParameter("acl", null);
          if (versionId != null) request.addParameter("versionId", versionId);
          populateRequesterPaysHeader(request, isRequesterPays);
  
          byte[] aclAsXml = new AclXmlFactory().convertToXmlByteArray(acl);
          request.addHeader("Content-Type", "application/xml");
          request.addHeader("Content-Length", String.valueOf(aclAsXml.length));
          request.setContent(new ByteArrayInputStream(aclAsXml));
  
          invoke(request, voidResponseHandler, bucketName, key);
      }
docs: Sets the ACL for the specified resource in S3. If only bucketName is
  specified, the ACL will be applied to the bucket, otherwise if bucketName
  and key are specified, the ACL will be applied to the object.
  
  @param bucketName
  The name of the bucket containing the specified key, or if no
  key is listed, the bucket whose ACL will be set.
  @param key
  The optional object key within the specified bucket whose ACL
  will be set. If not specified, the bucket ACL will be set.
  @param versionId
  The version ID of the object version whose ACL is being set.
  @param acl
  The ACL to apply to the resource.
  @param originalRequest
  The original, user facing request object.