當前位置: 首頁>>代碼示例>>Java>>正文


Java FormDataMultiPart類代碼示例

本文整理匯總了Java中org.glassfish.jersey.media.multipart.FormDataMultiPart的典型用法代碼示例。如果您正苦於以下問題:Java FormDataMultiPart類的具體用法?Java FormDataMultiPart怎麽用?Java FormDataMultiPart使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FormDataMultiPart類屬於org.glassfish.jersey.media.multipart包,在下文中一共展示了FormDataMultiPart類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPassThroughPostMultiPart

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
/**
 * Test to make sure that the proxy can proxy a redirect
 * @throws Exception
 */
@Test
public void testPassThroughPostMultiPart() throws Exception {
    final FileDataBodyPart filePart = new FileDataBodyPart("test_file", new File(TEST_IMAGE_PATH));

    MultiPart multiPart = new FormDataMultiPart()
            .field("foo", "bar")
            .bodyPart(filePart);
    Client multipartClient = ClientBuilder.newBuilder()
            .register(MultiPartFeature.class)
            .build();
    String responseBody = multipartClient.target("http://localhost:" + RULE.getLocalPort() + "/proxy")
            .request()
            .header("proxy-url", "http://httpbin.org/post")
            .post(Entity.entity(multiPart, multiPart.getMediaType()))
            .readEntity(String.class);
    assertTrue(responseBody.toLowerCase().contains("test_file"));
}
 
開發者ID:kunai-consulting,項目名稱:KeyStor,代碼行數:22,代碼來源:IntegrationTest.java

示例2: submit

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
public PredictResponse submit() throws IOException {
  FormDataMultiPart formPart = new FormDataMultiPart();
  formPart.field("modelId", modelId);
  formPart.field("sampleLocation", sampleLocation);

  MediaType contentType = formPart.getMediaType();
  contentType = Boundary.addBoundary(contentType);
  Entity<FormDataMultiPart> entity = Entity.entity(formPart, contentType);

  Response response = client.target(EINSTEIN_VISION_URL + "/v1/vision/predict")
      .request()
      .header("Authorization", "Bearer " + getToken())
      .post(entity);

  if (!isSuccessful(response)) {
    throw new IOException("Error occurred while making prediction call " + response);
  }

  return readResponseAs(response, PredictResponse.class);
}
 
開發者ID:MetaMind,項目名稱:quickstart,代碼行數:21,代碼來源:PredictRequest.java

示例3: uploadHomeFile

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private void uploadHomeFile() throws Exception {
  final FormDataMultiPart form = new FormDataMultiPart();
  final FormDataBodyPart fileBody = new FormDataBodyPart("file", com.dremio.common.util.FileUtils.getResourceAsString("/testfiles/yelp_biz.json"), MediaType.MULTIPART_FORM_DATA_TYPE);
  form.bodyPart(fileBody);
  form.bodyPart(new FormDataBodyPart("fileName", "biz"));

  com.dremio.file.File file1 = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/upload_start/").queryParam("extension", "json"))
      .buildPost(Entity.entity(form, form.getMediaType())), com.dremio.file.File.class);
  file1 = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/upload_finish/biz"))
      .buildPost(Entity.json(file1.getFileFormat().getFileFormat())), com.dremio.file.File.class);

  FileFormat fileFormat = file1.getFileFormat().getFileFormat();
  assertEquals(physicalFileAtHome.getLeaf().getName(), fileFormat.getName());
  assertEquals(physicalFileAtHome.toPathList(), fileFormat.getFullPath());
  assertEquals(FileType.JSON, fileFormat.getFileType());

  fileBody.cleanup();
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:19,代碼來源:TestAccelerationResource.java

示例4: formatChangeForUploadedHomeFile

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
@Test // DX-5410
public void formatChangeForUploadedHomeFile() throws Exception {
  FormDataMultiPart form = new FormDataMultiPart();
  FormDataBodyPart fileBody = new FormDataBodyPart("file", FileUtils.getResourceAsFile("/datasets/csv/pipe.csv"), MediaType.MULTIPART_FORM_DATA_TYPE);
  form.bodyPart(fileBody);
  form.bodyPart(new FormDataBodyPart("fileName", "pipe"));

  doc("uploading a text file");
  File file1 = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/upload_start/").queryParam("extension", "csv"))
      .buildPost(Entity.entity(form, form.getMediaType())), File.class);
  file1 = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/upload_finish/pipe"))
      .buildPost(Entity.json(file1.getFileFormat().getFileFormat())), File.class);
  final FileFormat defaultFileFormat = file1.getFileFormat().getFileFormat();

  assertTrue(defaultFileFormat instanceof TextFileConfig);
  assertEquals(",", ((TextFileConfig)defaultFileFormat).getFieldDelimiter());

  doc("change the format settings of uploaded file");
  final TextFileConfig newFileFormat = (TextFileConfig)defaultFileFormat;
  newFileFormat.setFieldDelimiter("|");

  final FileFormat updatedFileFormat = expectSuccess(getBuilder(getAPIv2().path("home/" + HOME_NAME + "/file_format/pipe"))
      .buildPut(Entity.json(newFileFormat)), FileFormatUI.class).getFileFormat();
  assertTrue(updatedFileFormat instanceof TextFileConfig);
  assertEquals("|", ((TextFileConfig)updatedFileFormat).getFieldDelimiter());
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:27,代碼來源:TestHomeFiles.java

示例5: getMultiPartForm

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
/**
 * Creates a MultiPart Form object
 * 
 * @param entity
 *            expects TPASCreativeBatchApprove entity.
 * @param formDataMultiPart
 *            expects a FormDataMultiPart object.
 * @return
 */
public static FormDataMultiPart getMultiPartForm(TPASCreativeBatchApprove entity,
		FormDataMultiPart formDataMultiPart) {

	FormDataMultiPart formData = formDataMultiPart;

	formData = setMultipartAdvertiserID(entity, formData);

	if (entity.getBatch() != null) {
		for (TPASCreativeBatchIndex batchIndex : entity.getBatch()) {
			if (batchIndex.getBatchIndex() != null && !batchIndex.getBatchIndex().isEmpty()) {

				formData = formData.field("batch_index", batchIndex.getBatchIndex());

				formData = setMultipartConcept(formData, batchIndex);

				formData = setMultipartClickURL(formData, batchIndex);
			}
		}
	}

	return formData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:32,代碼來源:TPasCreativeUploadBatchHelper.java

示例6: setMultipartClickURL

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setMultipartClickURL(FormDataMultiPart formDataMultiPart,
		TPASCreativeBatchIndex batchIndex) {
	FormDataMultiPart formData = formDataMultiPart;
	if (batchIndex.getClickUrl() != null && !batchIndex.getClickUrl().isEmpty()) {
		formData = formData.field("click_url_" + batchIndex.getBatchIndex(), batchIndex.getClickUrl());
	}
	return formData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TPasCreativeUploadBatchHelper.java

示例7: setMultipartConcept

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setMultipartConcept(FormDataMultiPart formDataMultiPart,
		TPASCreativeBatchIndex batchIndex) {
	FormDataMultiPart formData = formDataMultiPart;
	if (batchIndex.getConceptId() != null && !batchIndex.getConceptId().isEmpty()) {
		formData = formData.field("concept_" + batchIndex.getBatchIndex(), batchIndex.getConceptId());
	}
	return formData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TPasCreativeUploadBatchHelper.java

示例8: setMultipartAdvertiserID

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setMultipartAdvertiserID(TPASCreativeBatchApprove entity,
		FormDataMultiPart formDataMultiPart) {
	FormDataMultiPart formData = formDataMultiPart;
	if (entity.getAdvertiserId() != null && !entity.getAdvertiserId().isEmpty()) {
		formData = formData.field("advertiser_id", entity.getAdvertiserId());
	}
	return formData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TPasCreativeUploadBatchHelper.java

示例9: setConcept

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setConcept(FormDataMultiPart formData, int inc,
		TOneASCreativeAssetsApproveData data) {
	FormDataMultiPart localFormData = formData;
	if (data.getConcept() != null && !data.getConcept().isEmpty()) {
		localFormData = localFormData.field("concept." + inc, data.getConcept());
	}
	return localFormData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TOneCreativeAssetsApproveHelper.java

示例10: setBackup

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setBackup(FormDataMultiPart formData, int inc,
		TOneASCreativeAssetsApproveData data) {
	FormDataMultiPart localFormData = formData;
	if (data.getBackup() != null && !data.getBackup().isEmpty()) {
		localFormData = localFormData.field("backup." + inc, data.getBackup());
	}
	return localFormData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TOneCreativeAssetsApproveHelper.java

示例11: setPrimary

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setPrimary(FormDataMultiPart formData, int inc,
		TOneASCreativeAssetsApproveData data) {
	FormDataMultiPart localFormData = formData;
	if (data.getPrimary() != null && !data.getPrimary().isEmpty()) {
		localFormData = localFormData.field("primary." + inc, data.getPrimary());
	}
	return localFormData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TOneCreativeAssetsApproveHelper.java

示例12: setClickURL

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setClickURL(FormDataMultiPart formData, int inc,
		TOneASCreativeAssetsApproveData data) {
	FormDataMultiPart localFormData = formData;
	if (data.getClickUrl() != null && !data.getClickUrl().isEmpty()) {
		localFormData = localFormData.field("click_url." + inc, data.getClickUrl());
	}
	return localFormData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TOneCreativeAssetsApproveHelper.java

示例13: setLandingPage

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setLandingPage(FormDataMultiPart formData, int inc,
		TOneASCreativeAssetsApproveData data) {
	FormDataMultiPart localFormData = formData;
	if (data.getLandingPage() != null && !data.getLandingPage().isEmpty()) {
		localFormData = localFormData.field("landingPage." + inc, data.getLandingPage());
	}
	return localFormData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:9,代碼來源:TOneCreativeAssetsApproveHelper.java

示例14: setAdvertiserID

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setAdvertiserID(FormDataMultiPart formData, TOneASCreativeAssetsApproveData data) {
	FormDataMultiPart localFormData = formData;
	if (data.getAdvertiserid() != null && !data.getAdvertiserid().isEmpty()) {
		localFormData = localFormData.field("advertiserid", data.getAdvertiserid());
	}
	return localFormData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:8,代碼來源:TOneCreativeAssetsApproveHelper.java

示例15: setIsHttps

import org.glassfish.jersey.media.multipart.FormDataMultiPart; //導入依賴的package包/類
private static FormDataMultiPart setIsHttps(FormDataMultiPart formData, TOneASCreativeAssetsApproveData data) {
	FormDataMultiPart localFormData = formData;
	if (data.isHttps()) {
		localFormData = localFormData.field("is_https", Utility.getOneOrZero(data.isHttps()));
	}
	return localFormData;
}
 
開發者ID:MediaMath,項目名稱:t1-java,代碼行數:8,代碼來源:TOneCreativeAssetsApproveHelper.java


注:本文中的org.glassfish.jersey.media.multipart.FormDataMultiPart類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。