Java Code Examples for org.apache.http.entity.FileEntity

The following examples show how to use org.apache.http.entity.FileEntity. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: djl-demo   Source File: RequestHandler.java    License: Apache License 2.0 6 votes vote down vote up
/** Handles URLs predicted as malicious. */
private void blockedMaliciousSiteRequested() {
    try {
        HttpResponse response =
                new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_BAD_REQUEST, "MAL");
        HttpEntity httpEntity = new FileEntity(new File("index.html"), ContentType.WILDCARD);
        BufferedWriter bufferedWriter =
                new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
        bufferedWriter.write(response.getStatusLine().toString());
        String headers =
                "Proxy-agent: FilterProxy/1.0\r\n"
                        + httpEntity.getContentType().toString()
                        + "\r\n"
                        + "Content-Length: "
                        + httpEntity.getContentLength()
                        + "\r\n\r\n";
        bufferedWriter.write(headers);
        // Pass index.html content
        bufferedWriter.write(EntityUtils.toString(httpEntity));
        bufferedWriter.flush();
        bufferedWriter.close();
    } catch (IOException e) {
        logger.error("Error writing to client when requested a blocked site", e);
    }
}
 
Example 2
Source Project: gradle-plugins   Source File: HelmPublish.java    License: Apache License 2.0 6 votes vote down vote up
@TaskAction
public void run() throws IOException {
	Project project = getProject();
	HelmExtension extension = project.getExtensions().getByType(HelmExtension.class);
	HelmExtension helm = project.getExtensions().getByType(HelmExtension.class);

	CredentialsProvider credentialsProvider = getCredentialsProvider();
	Set<String> packageNames = helm.getPackageNames();

	for (String packageName : packageNames) {
		try (CloseableHttpClient client = HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build()) {
			String url = extension.getRepository() + "/" + packageName + "-" + project.getVersion() + ".tgz";
			File helmChart = helm.getOutputFile(packageName);
			HttpPut post = new HttpPut(url);

			FileEntity entity = new FileEntity(helmChart);
			post.setEntity(entity);

			HttpResponse response = client.execute(post);
			if (response.getStatusLine().getStatusCode() > 299) {
				throw new IOException(
						"failed to publish " + packageName + " to " + url + ", reason=" + response.getStatusLine());
			}
		}
	}
}
 
Example 3
Source Project: nexus-public   Source File: RawHostedIT.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void canDisallowDelete() throws Exception {
  rawClient = rawClient(repos.createRawHosted(HOSTED_REPO + "-no-delete"));

  HttpEntity testEntity = new FileEntity(resolveTestFile(TEST_CONTENT), TEXT_PLAIN);

  HttpResponse response = rawClient.put(TEST_CONTENT, testEntity);
  MatcherAssert.assertThat(response.getStatusLine().getStatusCode(), Matchers.is(HttpStatus.CREATED));

  Configuration hostedConfig = repositoryManager.get(HOSTED_REPO + "-no-delete").getConfiguration().copy();
  hostedConfig.attributes(STORAGE).set(WRITE_POLICY, DENY);
  repositoryManager.update(hostedConfig);

  response = rawClient.delete(TEST_CONTENT);
  MatcherAssert.assertThat(response.getStatusLine().getStatusCode(), Matchers.is(HttpStatus.BAD_REQUEST));
  assertThat(response.getStatusLine().getReasonPhrase(), Matchers.containsString("cannot be deleted"));
}
 
Example 4
/**
 * Attach the files given in the parameters.
 * 
 * @param request
 *            the current request
 * @param parameters
 *            the parameters
 * @since 0.7.3
 */
private void attachFiles(final HttpUriRequest request,
        final Collection<KeyValuePair> parameters) {
    if (!(request instanceof HttpPost)) {
        return;
    }
    final HttpPost post = (HttpPost) request;
    for (KeyValuePair current : parameters) {
        final Object value = current.getValue();
        if (value instanceof File) {
            final File file = (File) value;
            final FileEntity fileEntity = new FileEntity(file,
                    ContentType.create("binary/octet-stream"));
            post.setEntity(fileEntity);
        }
    }
}
 
Example 5
Source Project: ant-ivy   Source File: HttpClientHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void upload(final File src, final URL dest, final CopyProgressListener listener, final TimeoutConstraint timeoutConstraint) throws IOException {
    final int connectionTimeout = (timeoutConstraint == null || timeoutConstraint.getConnectionTimeout() < 0) ? 0 : timeoutConstraint.getConnectionTimeout();
    final int readTimeout = (timeoutConstraint == null || timeoutConstraint.getReadTimeout() < 0) ? 0 : timeoutConstraint.getReadTimeout();
    final RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeout)
            .setConnectTimeout(connectionTimeout)
            .setAuthenticationEnabled(hasCredentialsConfigured(dest))
            .setTargetPreferredAuthSchemes(getAuthSchemePreferredOrder())
            .setProxyPreferredAuthSchemes(getAuthSchemePreferredOrder())
            .setExpectContinueEnabled(true)
            .build();
    final HttpPut put = new HttpPut(normalizeToString(dest));
    put.setConfig(requestConfig);
    put.setEntity(new FileEntity(src));
    try (final CloseableHttpResponse response = this.httpClient.execute(put)) {
        validatePutStatusCode(dest, response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());
    }
}
 
Example 6
Source Project: knox   Source File: DeployResourceRequest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected Callable<BasicResponse> callable() {
  return () -> {
    URIBuilder uri = uri( "/admin/api/v1/", resourceType.getName(), "/", resourceName );
    HttpPut request = new HttpPut( uri.build() );

    if (resourceFileName != null) {
      File resource = new File(resourceFileName);
      if (!resource.exists()) {
        throw new FileNotFoundException(resourceFileName);
      }
      HttpEntity entity = new FileEntity(new File(resourceFileName), ContentType.APPLICATION_JSON);
      request.setEntity(entity);
    }
    return new BasicResponse( execute( request ) );
  };
}
 
Example 7
Source Project: java-client-api   Source File: TestServerBootstrapper.java    License: Apache License 2.0 6 votes vote down vote up
private void installBootstrapExtension() throws IOException {

    DefaultHttpClient client = new DefaultHttpClient();

    client.getCredentialsProvider().setCredentials(
      new AuthScope(host, port),
      new UsernamePasswordCredentials(username, password));

    HttpPut put = new HttpPut("http://" + host + ":" + port
      + "/v1/config/resources/bootstrap?method=POST&post%3Abalanced=string%3F");

    put.setEntity(new FileEntity(new File("src/test/resources/bootstrap.xqy"), "application/xquery"));
    HttpResponse response = client.execute(put);
    @SuppressWarnings("unused")
    HttpEntity entity = response.getEntity();
    System.out.println("Installed bootstrap extension.  Response is "
      + response.toString());

  }
 
Example 8
Source Project: cxf   Source File: JAXRSClientServerSpringBookTest.java    License: Apache License 2.0 6 votes vote down vote up
private void doPost(String endpointAddress, int expectedStatus, String contentType,
                    String inResource, String expectedResource) throws Exception {

    File input = new File(getClass().getResource(inResource).toURI());
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpPost post = new HttpPost(endpointAddress);
    post.setHeader("Content-Type", contentType);
    post.setEntity(new FileEntity(input, ContentType.TEXT_XML));

    try {
        CloseableHttpResponse response = client.execute(post);
        assertEquals(expectedStatus, response.getStatusLine().getStatusCode());

        if (expectedStatus != 400) {
            InputStream expected = getClass().getResourceAsStream(expectedResource);
            assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
                         stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
        } else {
            assertTrue(EntityUtils.toString(response.getEntity())
                           .contains("Cannot find the declaration of element"));
        }
    } finally {
        // Release current connection to the connection pool once you are done
        post.releaseConnection();
    }
}
 
Example 9
Source Project: cxf   Source File: JAXRSSoapBookTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAddGetBookRest() throws Exception {

    String endpointAddress =
        "http://localhost:" + PORT + "/test/services/rest/bookstore/books";

    File input = new File(getClass().getResource("resources/add_book.txt").toURI());
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpPost post = new HttpPost(endpointAddress);
    post.addHeader("Content-Type", "application/xml");
    post.setEntity(new FileEntity(input, ContentType.TEXT_XML));

    try {
        CloseableHttpResponse response = client.execute(post);
        assertEquals(200, response.getStatusLine().getStatusCode());

        InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");

        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
                     stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
    } finally {
        // Release current connection to the connection pool once you are done
        post.releaseConnection();
    }

}
 
Example 10
Source Project: cxf   Source File: JAXRSClientServerBookTest.java    License: Apache License 2.0 6 votes vote down vote up
private void doAddBook(String address) throws Exception {
    File input = new File(getClass().getResource("resources/add_book.txt").toURI());
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpPost post = new HttpPost(address);
    post.addHeader("Content-Type", "application/xml");
    post.setEntity(new FileEntity(input, ContentType.TEXT_XML));

    try {
        CloseableHttpResponse response = client.execute(post);
        assertEquals(200, response.getStatusLine().getStatusCode());

        InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");

        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
                     stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
    } finally {
        // Release current connection to the connection pool once you are done
        post.releaseConnection();
    }
}
 
Example 11
Source Project: cxf   Source File: JAXRSClientServerBookTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateBook() throws Exception {
    String endpointAddress = "http://localhost:" + PORT + "/bookstore/books";

    File input = new File(getClass().getResource("resources/update_book.txt").toURI());
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpPut put = new HttpPut(endpointAddress);
    put.setEntity(new FileEntity(input, ContentType.TEXT_XML));

    try {
        CloseableHttpResponse response = client.execute(put);
        assertEquals(200, response.getStatusLine().getStatusCode());
        InputStream expected = getClass().getResourceAsStream("resources/expected_update_book.txt");
        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
                     stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
    } finally {
        // Release current connection to the connection pool once you are
        // done
        put.releaseConnection();
    }
}
 
Example 12
Source Project: cxf   Source File: JAXRSClientServerBookTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateBookWithDom() throws Exception {
    String endpointAddress = "http://localhost:" + PORT + "/bookstore/bookswithdom";

    File input = new File(getClass().getResource("resources/update_book.txt").toURI());
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpPut put = new HttpPut(endpointAddress);
    put.setEntity(new FileEntity(input, ContentType.TEXT_XML));
    try {
        CloseableHttpResponse response = client.execute(put);
        assertEquals(200, response.getStatusLine().getStatusCode());
        String resp = EntityUtils.toString(response.getEntity());
        InputStream expected = getClass().getResourceAsStream("resources/update_book.txt");
        String s = getStringFromInputStream(expected);
        //System.out.println(resp);
        //System.out.println(s);
        assertTrue(resp.indexOf(s) >= 0);
    } finally {
        // Release current connection to the connection pool once you are
        // done
        put.releaseConnection();
    }
}
 
Example 13
Source Project: cxf   Source File: JAXRSClientServerBookTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateBookWithJSON() throws Exception {
    String endpointAddress = "http://localhost:" + PORT + "/bookstore/bookswithjson";

    File input = new File(getClass().getResource("resources/update_book_json.txt").toURI());
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpPut put = new HttpPut(endpointAddress);
    put.setEntity(new FileEntity(input, ContentType.APPLICATION_JSON));

    try {
        CloseableHttpResponse response = client.execute(put);
        assertEquals(200, response.getStatusLine().getStatusCode());
        InputStream expected = getClass().getResourceAsStream("resources/expected_update_book.txt");
        assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
                     stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
    } finally {
        // Release current connection to the connection pool once you are
        // done
        put.releaseConnection();
    }
}
 
Example 14
Source Project: cxf   Source File: JAXRSClientServerBookTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateBookFailed() throws Exception {
    String endpointAddress =
        "http://localhost:" + PORT + "/bookstore/books";

    File input = new File(getClass().getResource("resources/update_book_not_exist.txt").toURI());
    CloseableHttpClient client = HttpClientBuilder.create().build();
    HttpPut put = new HttpPut(endpointAddress);
    put.setEntity(new FileEntity(input, ContentType.TEXT_XML));

    try {
        CloseableHttpResponse response = client.execute(put);
        assertEquals(304, response.getStatusLine().getStatusCode());
    } finally {
        // Release current connection to the connection pool once you are done
        put.releaseConnection();
    }
}
 
Example 15
Source Project: RoboZombie   Source File: RequestParamEndpointTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * <p>Test for a {@link Request} with a {@link File} entity.</p>
 * 
 * @since 1.3.0
 */
@Test
public final void testFileEntity() throws ParseException, IOException, URISyntaxException {
	
	Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
	
	String subpath = "/fileentity";
	
	ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
	File file = new File(classLoader.getResource("LICENSE.txt").toURI());
	FileEntity fe = new FileEntity(file, null);
	
	stubFor(put(urlEqualTo(subpath))
			.willReturn(aResponse()
			.withStatus(200)));
	
	requestEndpoint.fileEntity(file);
	
	verify(putRequestedFor(urlEqualTo(subpath))
		   .withRequestBody(equalTo(EntityUtils.toString(fe))));
}
 
Example 16
Source Project: jkube   Source File: ApacheHttpClientDelegate.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void setEntityIfGiven(HttpEntityEnclosingRequestBase request, Object entity) {
    if (entity != null) {
        if (entity instanceof File) {
            request.setEntity(new FileEntity((File) entity));
        } else {
            request.setEntity(new StringEntity((String) entity, Charset.defaultCharset()));
        }
    }
}
 
Example 17
Source Project: Photato   Source File: VideoHandler.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HttpEntity getEntity(String path, Map<String, String> query, File localFile) throws IOException {
    String extension = FileHelper.getExtension(path);
    ContentType contentType = ContentType.create(getContentType(extension.toLowerCase()));

    return new FileEntity(localFile, contentType);
}
 
Example 18
Source Project: Photato   Source File: ImageHandler.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected HttpEntity getEntity(String path, Map<String, String> query, File localFile) throws IOException {
    String extension = FileHelper.getExtension(path);
    ContentType contentType = ContentType.create(getContentType(extension.toLowerCase()));

    return new FileEntity(localFile, contentType);
}
 
Example 19
Source Project: PYX-Reloaded   Source File: TwitterAuthHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Response execute(String userAgent, Map<String, String> headers, Verb httpVerb, String completeUrl, File bodyContents) throws IOException {
    HttpRequestBase request = initialSetup(httpVerb, completeUrl, userAgent, headers);
    if (request instanceof HttpEntityEnclosingRequestBase)
        ((HttpEntityEnclosingRequestBase) request).setEntity(new FileEntity(bodyContents));

    return execute(request);
}
 
Example 20
@Override
public void setPostEntity(File file, HttpPost httppost) {
    httppost.setHeader("Content-Type", "application/octet-stream");
    httppost.setHeader("Slug", file.getName());
    HttpEntity e = new FileEntity(file, ContentType.create(MIME.getType(file)));
    httppost.setEntity(e);
}
 
Example 21
Source Project: nexus-public   Source File: RawHostedIT.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void canDisallowDeploy() throws Exception {
  rawClient = rawClient(repos.createRawHosted(HOSTED_REPO + "-no-deploy", DENY));

  HttpEntity testEntity = new FileEntity(resolveTestFile(TEST_CONTENT), TEXT_PLAIN);

  HttpResponse response = rawClient.put(TEST_CONTENT, testEntity);
  MatcherAssert.assertThat(response.getStatusLine().getStatusCode(), Matchers.is(HttpStatus.BAD_REQUEST));
  assertThat(response.getStatusLine().getReasonPhrase(), Matchers.containsString("is read-only"));
}
 
Example 22
Source Project: nexus-public   Source File: RawHostedIT.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void canDisallowRedeploy() throws Exception {
  rawClient = rawClient(repos.createRawHosted(HOSTED_REPO + "-no-redeploy", ALLOW_ONCE));

  HttpEntity testEntity = new FileEntity(resolveTestFile(TEST_CONTENT), TEXT_PLAIN);

  HttpResponse response = rawClient.put(TEST_CONTENT, testEntity);
  MatcherAssert.assertThat(response.getStatusLine().getStatusCode(), Matchers.is(HttpStatus.CREATED));

  response = rawClient.put(TEST_CONTENT, testEntity);
  MatcherAssert.assertThat(response.getStatusLine().getStatusCode(), Matchers.is(HttpStatus.BAD_REQUEST));
  assertThat(response.getStatusLine().getReasonPhrase(), Matchers.containsString("cannot be updated"));
}
 
Example 23
Source Project: packagedrone   Source File: UploadApiV3Test.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected CloseableHttpResponse upload ( final URIBuilder uri, final File file ) throws IOException, URISyntaxException
{
    final HttpPut http = new HttpPut ( uri.build () );

    final String encodedAuth = Base64.getEncoder ().encodeToString ( uri.getUserInfo ().getBytes ( StandardCharsets.ISO_8859_1 ) );

    http.setHeader ( HttpHeaders.AUTHORIZATION, "Basic " + encodedAuth );

    http.setEntity ( new FileEntity ( file ) );
    return httpclient.execute ( http );
}
 
Example 24
Source Project: packagedrone   Source File: UploadApiV2Test.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected CloseableHttpResponse upload ( final URIBuilder uri, final File file ) throws IOException, URISyntaxException
{
    final HttpPut httppost = new HttpPut ( uri.build () );
    httppost.setEntity ( new FileEntity ( file ) );

    return httpclient.execute ( httppost );
}
 
Example 25
Source Project: streamsx.topology   Source File: StreamsRestActions.java    License: Apache License 2.0 5 votes vote down vote up
static ApplicationBundle uploadBundle(Instance instance, File bundle) throws IOException {
		
Request postBundle = Request.Post(instance.self() + "/applicationbundles");
postBundle.addHeader(AUTH.WWW_AUTH_RESP, instance.connection().getAuthorization());
postBundle.body(new FileEntity(bundle, ContentType.create("application/x-jar")));

JsonObject response = requestGsonResponse(instance.connection().executor, postBundle);

UploadedApplicationBundle uab = Element.createFromResponse(instance.connection(), response, UploadedApplicationBundle.class);
uab.setInstance(instance);
return uab;
  }
 
Example 26
Source Project: galaxy-fds-sdk-java   Source File: GalaxyFDSClient.java    License: Apache License 2.0 5 votes vote down vote up
private PutObjectResult uploadWithFile(String bucketName, String objectName, File file,
    FDSObjectMetadata metadata) throws GalaxyFDSClientException {
  if (this.fdsConfig.isMd5CalculateEnabled()) {
    throw new GalaxyFDSClientException(
        "Upload with File object and MD5 calculate enabled is not supported");
  }

  ContentType contentType = ContentType.APPLICATION_OCTET_STREAM;
  if (metadata == null) {
    metadata = new FDSObjectMetadata();
  }

  if (metadata.getContentType() != null) {
    contentType = ContentType.create(metadata.getContentType());
  }

  URI uri = formatUri(fdsConfig.getUploadBaseUri(),
    bucketName + "/" + (objectName == null ? "" : objectName), (SubResource[]) null);
  FileEntity requestEntity = new FileEntity(file, contentType);

  HttpMethod m = objectName == null ? HttpMethod.POST : HttpMethod.PUT;
  HttpUriRequest httpRequest = fdsHttpClient.prepareRequestMethod(uri, m, contentType, metadata,
    null, null, requestEntity);

  HttpResponse response = fdsHttpClient.executeHttpRequest(httpRequest,
    objectName == null ? Action.PostObject : Action.PutObject);

  return (PutObjectResult) fdsHttpClient.processResponse(response, PutObjectResult.class,
    m.name() + " object [" + objectName + "] to bucket [" + bucketName + "]");
}
 
Example 27
private void setEntityIfGiven(HttpEntityEnclosingRequestBase request, Object entity) {
    if (entity != null) {
        if (entity instanceof File) {
            request.setEntity(new FileEntity((File) entity));
        } else {
            request.setEntity(new StringEntity((String) entity, Charset.defaultCharset()));
        }
    }
}
 
Example 28
Source Project: cs-actions   Source File: EntityBuilderTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void buildEntityWithFile() throws Exception {
    ContentType parsedContentType = ContentType.parse(CONTENT_TYPE);
    final String fileName = "testFile.txt";
    PowerMockito.whenNew(File.class).withArguments(fileName).thenReturn(fileMock);
    PowerMockito.when(fileMock.exists()).thenReturn(true);

    HttpEntity httpEntity = entityBuilder
            .setFilePath(fileName)
            .setContentType(parsedContentType)
            .buildEntity();
    assertThat(httpEntity, instanceOf(FileEntity.class));
    FileEntity fileEntity = (FileEntity) httpEntity;
    assertEquals(CONTENT_TYPE, fileEntity.getContentType().getValue());
}
 
Example 29
Source Project: openregistry   Source File: ORRESTTool.java    License: Apache License 2.0 5 votes vote down vote up
private static HttpResponse doPost(DefaultHttpClient httpclient, String url, File file) throws IOException{
	HttpPost method = new HttpPost(url);
	if (file != null){
		FileEntity fileEntity = new FileEntity(file, "application/xml; charset=\"UTF-8\"");
		method.setEntity(fileEntity);
	}
	  	
	return httpclient.execute(method);	
}
 
Example 30
Source Project: openregistry   Source File: ORRESTTool.java    License: Apache License 2.0 5 votes vote down vote up
private static HttpResponse doPut(DefaultHttpClient httpclient, String url, File file) throws IOException{
	HttpPut method = new HttpPut(url);
	if (file != null){
		FileEntity fileEntity = new FileEntity(file, "application/xml; charset=\"UTF-8\"");
		method.setEntity(fileEntity);
	}
	  	
	return httpclient.execute(method);	
}