当前位置: 首页>>代码示例>>Java>>正文


Java类org.apache.http.entity.mime.MIME代码示例

以下是Javaorg.apache.http.entity.mime.MIME的代码示例。类MIME属于org.apache.http.entity.mime包,如果您正苦于以下问题:Java MIME类的具体用法?Java MIME怎么用?Java MIME使用的例子?那么恭喜您, 这里整理的类代码示例例程将为您提供帮助。

本文一共展示了MIME的15个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: DelayedHttpMultipartEntity

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
/**
 * @param status Length
 */
public DelayedHttpMultipartEntity(final String filename, final TransferStatus status, final String boundary) {
    this.status = status;
    final StringBuilder multipartHeader = new StringBuilder();
    multipartHeader.append(TWO_DASHES);
    multipartHeader.append(boundary);
    multipartHeader.append(CR_LF);
    multipartHeader.append(String.format("Content-Disposition: form-data; name=\"file\"; filename=\"%s\"", filename));
    multipartHeader.append(CR_LF);
    multipartHeader.append(String.format("%s: %s", HTTP.CONTENT_TYPE, StringUtils.isBlank(status.getMime()) ? MimeTypeService.DEFAULT_CONTENT_TYPE : status.getMime()));
    multipartHeader.append(CR_LF);
    multipartHeader.append(CR_LF);
    header = encode(MIME.DEFAULT_CHARSET, multipartHeader.toString()).buffer();
    final StringBuilder multipartFooter = new StringBuilder();
    multipartFooter.append(CR_LF);
    multipartFooter.append(TWO_DASHES);
    multipartFooter.append(boundary);
    multipartFooter.append(TWO_DASHES);
    multipartFooter.append(CR_LF);
    footer = encode(MIME.DEFAULT_CHARSET, multipartFooter.toString()).buffer();
}
 
开发者ID:iterate-ch,项目:cyberduck,完整代码来源:DelayedHttpMultipartEntity.java


示例2: testUpdateRequest

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
@Test
public void testUpdateRequest() {

	UpdateRequest updateRequest = Mockito.mock(UpdateRequest.class);

	when(updateRequest.getCommand()).thenReturn("getUpdates");

	MultipartEntityBuilder requestEntity = MultipartEntityBuilder.create();
	// New MIME type, data need to be UTF-8 encrypted
	ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);

	// Set timout, limit and offset
	requestEntity.addTextBody("timeout", "60", contentType);
	requestEntity.addTextBody("limit", "100", contentType);
	requestEntity.addTextBody("offset", "1337", contentType);

	when(updateRequest.getRequestEntity()).thenReturn(requestEntity);

	BotRequest request = new BotRequest(updateRequest);
	assertEquals("getUpdates", request.getCommand());
	assertEquals(requestEntity, request.getContent());
}
 
开发者ID:marzn,项目:telegrambot-japi,完整代码来源:TestBotRequest.java


示例3: runJob

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
/**
 * Runs a job with the defined parameters.
 * 
 * @param jobName name of the job
 * @param jobParameters job parameters for the execution
 * @param springBatchServiceUri the URI of Spring Batch Admin
 * @return JobExecution
 * @throws ServiceNotAvailableException
 * @throws ServiceInternalServerError
 * @throws Exception
 */
public static JobExecution runJob(String jobName, String jobParameters,
    String springBatchServiceUri) throws ResourceNotFoundException, UnknownException,
    IOException, ServiceNotAvailableException, ServiceInternalServerError {
  HttpPost postJob = new HttpPost(springBatchServiceUri + "/jobs/" + jobName + ".json");
  postJob.addHeader(MIME.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);

  log.debug("execute " + jobName + " with parameters: " + jobParameters);
  ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
  postParameters.add(new BasicNameValuePair("jobParameters", jobParameters));
  postJob.setEntity(new UrlEncodedFormEntity(postParameters));

  String jsonString = apiRequest(postJob);
  Gson gson = new Gson();
  JobExecutionWrapper execution = gson.fromJson(jsonString, JobExecutionWrapper.class);
  return execution.getJobExecution();
}
 
开发者ID:GeoKnow,项目:GeoKnowGeneratorUI,完整代码来源:BatchAdminClient.java


示例4: doCreate

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
@Override
protected ContentResult doCreate(Response response, InputStream resultStream, Runnable closeResult) {
  final int length = response.getHeaderValue("Content-Length", -1);
  final String format = response.getHeaderValue(MIME.CONTENT_TYPE, MediaTypes.BINARY);
  final String name = extractFileNameFrom(response.getHeaderValue(MIME.CONTENT_DISPOSITION, ""));
  return new DefaultContentResult(name, length, format, resultStream, closeResult);
}
 
开发者ID:Enterprise-Content-Management,项目:infoarchive-sip-sdk,完整代码来源:ContentResultFactory.java


示例5: handleResponse

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
@Override
public T handleResponse(HttpResponse httpResponse) throws IOException {
  StatusLine statusLine = httpResponse.getStatusLine();
  if (statusLine.getStatusCode() == 200) {
    String result = EntityUtils.toString(httpResponse.getEntity(), MIME.UTF8_CHARSET);
    Gson gson = new Gson();
    return gson.fromJson(result, resultClass);
  } else {
    throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
  }
}
 
开发者ID:Cognifide,项目:aet,完整代码来源:JsonResponseHandler.java


示例6: UpdateRequest

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
public UpdateRequest(Integer nextExpectedMsg) {
	this.offset = nextExpectedMsg;

	this.requestEntity = MultipartEntityBuilder.create();
	// New MIME type, data need to be UTF-8 encrypted
	ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);

	// Set timout, limit and offset
	requestEntity.addTextBody(KEY_MSG_UPDATE_TIMEOUT, TIMEOUT.toString(), contentType);
	requestEntity.addTextBody(KEY_MSG_UPDATE_LIMIT, LIMIT.toString(), contentType);
	requestEntity.addTextBody(KEY_MSG_UPDATE_OFFSET, offset.toString(), contentType);

}
 
开发者ID:marzn,项目:telegrambot-japi,完整代码来源:UpdateRequest.java


示例7: BotRequest

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
/**
 * Send a message to Telegram. This could be a text, image, audio, ...
 * message.
 * 
 * @param message
 */
public BotRequest(Message message) {
	this.command = message.getCommand();

	this.requestEntity = MultipartEntityBuilder.create();
	// New MIME type, data need to be UTF-8 encrypted
	ContentType contentType = ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), MIME.UTF8_CHARSET);

	// Set recipient, needed for every message
	requestEntity.addTextBody(KEY_RECIPIENT, message.getRecipient().toString(), contentType);

	// Add some more things, like a message text or an image
	switch (message.getMessageType()) {

	case TEXT_MESSAGE:
		requestEntity.addTextBody(message.getJsonKey(), (String) message.getMessage(), contentType);
		break;

	case IMAGE_MESSAGE:
	case DOCUMENT_MESSAGE:
	case AUDIO_MESSAGE:
	case VIDEO_MESSAGE:
		requestEntity.addBinaryBody(message.getJsonKey(), (File) message.getMessage());
		break;

	default:
		LOG.error("Message type is invalid, not supported or not yet implemented");
		break;
	}
}
 
开发者ID:marzn,项目:telegrambot-japi,完整代码来源:BotRequest.java


示例8: createMultipartBodypart

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
protected FormBodyPart createMultipartBodypart(String name, String message, String contentType) {
	FormBodyPartBuilder bodyPart = FormBodyPartBuilder.create()
		.setName(name)
		.setBody(new StringBody(message, ContentType.create(contentType, getCharSet())));

	if (StringUtils.isNotEmpty(getMtomContentTransferEncoding()))
		bodyPart.setField(MIME.CONTENT_TRANSFER_ENC, getMtomContentTransferEncoding());

	return bodyPart.build();
}
 
开发者ID:ibissource,项目:iaf,完整代码来源:HttpSender.java


示例9: getTransferEncoding

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
 
开发者ID:JackChan1999,项目:boohee_v5.6,完整代码来源:FileBody.java


示例10: getTransferEncoding

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
 
开发者ID:JackChan1999,项目:boohee_v5.6,完整代码来源:StringBody.java


示例11: getTransferEncoding

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
public String getTransferEncoding() {
	return (MIME.ENC_BINARY);
}
 
开发者ID:williamgrosset,项目:OSCAR-ConCert,完整代码来源:ByteArrayBody.java


示例12: getTransferEncoding

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
@Override
public String getTransferEncoding() {
    return MIME.ENC_BINARY;
}
 
开发者ID:MyPureCloud,项目:purecloud-iot,完整代码来源:FileBody.java


示例13: getTransferEncoding

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
@Override
public String getTransferEncoding() {
    return MIME.ENC_8BIT;
}
 
开发者ID:MyPureCloud,项目:purecloud-iot,完整代码来源:StringBody.java


示例14: getTransferEncoding

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
@Override
public String getTransferEncoding() {
	return MIME.ENC_BINARY;
}
 
开发者ID:lucee,项目:Lucee4,完整代码来源:ResourceBody.java


示例15: getTransferEncoding

import org.apache.http.entity.mime.MIME; //导入依赖的package包/类
@Override
public String getTransferEncoding() {
  return MIME.ENC_BINARY;
}
 
开发者ID:kaaproject,项目:kaa,完整代码来源:ByteArrayBody.java



注:本文示例均筛选自Github平台上各路大神开发的开源项目,代码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。