本文整理匯總了Java中com.sun.jersey.multipart.FormDataMultiPart.field方法的典型用法代碼示例。如果您正苦於以下問題:Java FormDataMultiPart.field方法的具體用法?Java FormDataMultiPart.field怎麽用?Java FormDataMultiPart.field使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.jersey.multipart.FormDataMultiPart
的用法示例。
在下文中一共展示了FormDataMultiPart.field方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serialize
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* Serialize the given Java object into string according the given
* Content-Type (only JSON is supported for now).
*/
public Object serialize(Object obj, String contentType, Map<String, Object> formParams) throws ApiException {
if (contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
File file = (File) param.getValue();
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
} else {
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
}
}
return mp;
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
return this.getXWWWFormUrlencodedParams(formParams);
} else {
// We let Jersey attempt to serialize the body
return obj;
}
}
示例2: serialize
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* Serialize the given Java object into string according the given
* Content-Type (only JSON is supported for now).
*/
public Object serialize(Object obj, String contentType, Map<String, Object> formParams) throws ApiException {
if (contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
for (Entry<String, Object> param : formParams.entrySet()) {
if (param.getValue() instanceof File) {
File file = (File) param.getValue();
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
} else {
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
}
}
return mp;
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
return this.getXWWWFormUrlencodedParams(formParams);
} else {
// We let Jersey attempt to serialize the body
return obj;
}
}
示例3: PostImageBmp
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PostImageBmp
* Update parameters of bmp image.
* @param bitsPerPixel Integer Color depth.
* @param horizontalResolution Integer New horizontal resolution.
* @param verticalResolution Integer New vertical resolution.
* @param fromScratch Boolean Specifies where additional parameters we do not support should be taken from. If this is true � they will be taken from default values for standard image, if it is false � they will be saved from current image. Default is false.
* @param outPath String Path to updated file, if this is empty, response contains streamed image.
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PostImageBmp (Integer bitsPerPixel, Integer horizontalResolution, Integer verticalResolution, Boolean fromScratch, String outPath, File file) {
Object postBody = null;
// verify required params are set
if(bitsPerPixel == null || horizontalResolution == null || verticalResolution == null || file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/imaging/bmp/?appSid={appSid}&bitsPerPixel={bitsPerPixel}&horizontalResolution={horizontalResolution}&verticalResolution={verticalResolution}&fromScratch={fromScratch}&outPath={outPath}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(bitsPerPixel!=null)
resourcePath = resourcePath.replace("{" + "bitsPerPixel" + "}" , apiInvoker.toPathValue(bitsPerPixel));
else
resourcePath = resourcePath.replaceAll("[&?]bitsPerPixel.*?(?=&|\\?|$)", "");
if(horizontalResolution!=null)
resourcePath = resourcePath.replace("{" + "horizontalResolution" + "}" , apiInvoker.toPathValue(horizontalResolution));
else
resourcePath = resourcePath.replaceAll("[&?]horizontalResolution.*?(?=&|\\?|$)", "");
if(verticalResolution!=null)
resourcePath = resourcePath.replace("{" + "verticalResolution" + "}" , apiInvoker.toPathValue(verticalResolution));
else
resourcePath = resourcePath.replaceAll("[&?]verticalResolution.*?(?=&|\\?|$)", "");
if(fromScratch!=null)
resourcePath = resourcePath.replace("{" + "fromScratch" + "}" , apiInvoker.toPathValue(fromScratch));
else
resourcePath = resourcePath.replaceAll("[&?]fromScratch.*?(?=&|\\?|$)", "");
if(outPath!=null)
resourcePath = resourcePath.replace("{" + "outPath" + "}" , apiInvoker.toPathValue(outPath));
else
resourcePath = resourcePath.replaceAll("[&?]outPath.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "POST", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例4: PostSlidesDocument
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PostSlidesDocument
* Create presentation
* @param name String The document name.
* @param templatePath String Template file path.
* @param templateStorage String Template storage name.
* @param isImageDataEmbeeded Boolean Is Image Data Embeeded
* @param password String The document password.
* @param storage String Document's storage.
* @param folder String Document's folder.
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PostSlidesDocument (String name, String templatePath, String templateStorage, Boolean isImageDataEmbeeded, String password, String storage, String folder, File file) {
Object postBody = null;
// verify required params are set
if(name == null || templatePath == null || file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/slides/{name}/?appSid={appSid}&templatePath={templatePath}&templateStorage={templateStorage}&isImageDataEmbeeded={isImageDataEmbeeded}&password={password}&storage={storage}&folder={folder}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(name!=null)
resourcePath = resourcePath.replace("{" + "name" + "}" , apiInvoker.toPathValue(name));
else
resourcePath = resourcePath.replaceAll("[&?]name.*?(?=&|\\?|$)", "");
if(templatePath!=null)
resourcePath = resourcePath.replace("{" + "templatePath" + "}" , apiInvoker.toPathValue(templatePath));
else
resourcePath = resourcePath.replaceAll("[&?]templatePath.*?(?=&|\\?|$)", "");
if(templateStorage!=null)
resourcePath = resourcePath.replace("{" + "templateStorage" + "}" , apiInvoker.toPathValue(templateStorage));
else
resourcePath = resourcePath.replaceAll("[&?]templateStorage.*?(?=&|\\?|$)", "");
if(isImageDataEmbeeded!=null)
resourcePath = resourcePath.replace("{" + "isImageDataEmbeeded" + "}" , apiInvoker.toPathValue(isImageDataEmbeeded));
else
resourcePath = resourcePath.replaceAll("[&?]isImageDataEmbeeded.*?(?=&|\\?|$)", "");
if(password!=null)
resourcePath = resourcePath.replace("{" + "password" + "}" , apiInvoker.toPathValue(password));
else
resourcePath = resourcePath.replaceAll("[&?]password.*?(?=&|\\?|$)", "");
if(storage!=null)
resourcePath = resourcePath.replace("{" + "storage" + "}" , apiInvoker.toPathValue(storage));
else
resourcePath = resourcePath.replaceAll("[&?]storage.*?(?=&|\\?|$)", "");
if(folder!=null)
resourcePath = resourcePath.replace("{" + "folder" + "}" , apiInvoker.toPathValue(folder));
else
resourcePath = resourcePath.replaceAll("[&?]folder.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "POST", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例5: PutConvertWorkBook
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PutConvertWorkBook
* Convert workbook from request content to some format.
* @param format String The format to convert.
* @param password String The workbook password.
* @param outPath String Path to save result
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PutConvertWorkBook (String format, String password, String outPath, File file, Object data) {
Object postBody = null;
// verify required params are set
if(file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/cells/convert/?appSid={appSid}&toFormat={toFormat}&password={password}&outPath={outPath}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(format!=null)
resourcePath = resourcePath.replace("{" + "format" + "}" , apiInvoker.toPathValue(format));
else
resourcePath = resourcePath.replaceAll("[&?]format.*?(?=&|\\?|$)", "");
if(password!=null)
resourcePath = resourcePath.replace("{" + "password" + "}" , apiInvoker.toPathValue(password));
else
resourcePath = resourcePath.replaceAll("[&?]password.*?(?=&|\\?|$)", "");
if(outPath!=null)
resourcePath = resourcePath.replace("{" + "outPath" + "}" , apiInvoker.toPathValue(outPath));
else
resourcePath = resourcePath.replaceAll("[&?]outPath.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
if(data!=null)
mp.field("data", data, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "PUT", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例6: PutWorkbookCreate
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PutWorkbookCreate
* Create new workbook using deferent methods.
* @param name String The new document name.
* @param templateFile String The template file, if the data not provided default workbook is created.
* @param dataFile String Smart marker data file, if the data not provided the request content is checked for the data.
* @param storage String The document storage.
* @param folder String The new document folder.
* @param file File
* @return WorkbookResponse
*/
public WorkbookResponse PutWorkbookCreate (String name, String templateFile, String dataFile, String storage, String folder, File file) {
Object postBody = null;
// verify required params are set
if(name == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/cells/{name}/?appSid={appSid}&templateFile={templateFile}&dataFile={dataFile}&storage={storage}&folder={folder}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(name!=null)
resourcePath = resourcePath.replace("{" + "name" + "}" , apiInvoker.toPathValue(name));
else
resourcePath = resourcePath.replaceAll("[&?]name.*?(?=&|\\?|$)", "");
if(templateFile!=null)
resourcePath = resourcePath.replace("{" + "templateFile" + "}" , apiInvoker.toPathValue(templateFile));
else
resourcePath = resourcePath.replaceAll("[&?]templateFile.*?(?=&|\\?|$)", "");
if(dataFile!=null)
resourcePath = resourcePath.replace("{" + "dataFile" + "}" , apiInvoker.toPathValue(dataFile));
else
resourcePath = resourcePath.replaceAll("[&?]dataFile.*?(?=&|\\?|$)", "");
if(storage!=null)
resourcePath = resourcePath.replace("{" + "storage" + "}" , apiInvoker.toPathValue(storage));
else
resourcePath = resourcePath.replaceAll("[&?]storage.*?(?=&|\\?|$)", "");
if(folder!=null)
resourcePath = resourcePath.replace("{" + "folder" + "}" , apiInvoker.toPathValue(folder));
else
resourcePath = resourcePath.replaceAll("[&?]folder.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"application/json"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(file!=null) {
contentType = "multipart/form-data";
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "PUT", queryParams, postBody, headerParams, formParams, contentType);
return (WorkbookResponse) ApiInvoker.deserialize(response, "", WorkbookResponse.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例7: PutCopy
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PutCopy
* Copy a specific file. Parameters: path - source file path e.g. /file.ext, versionID - source file's version, storage - user's source storage name, newdest - destination file path, destStorage - user's destination storage name.
* @param Path String
* @param newdest String
* @param versionId String
* @param storage String
* @param destStorage String
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PutCopy (String Path, String newdest, String versionId, String storage, String destStorage, File file) {
Object postBody = null;
// verify required params are set
if(Path == null || newdest == null || file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/storage/file/{Path}/?appSid={appSid}&newdest={newdest}&versionId={versionId}&storage={storage}&destStorage={destStorage}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(Path!=null)
resourcePath = resourcePath.replace("{" + "Path" + "}" , apiInvoker.toPathValue(Path));
else
resourcePath = resourcePath.replaceAll("[&?]Path.*?(?=&|\\?|$)", "");
if(newdest!=null)
resourcePath = resourcePath.replace("{" + "newdest" + "}" , apiInvoker.toPathValue(newdest));
else
resourcePath = resourcePath.replaceAll("[&?]newdest.*?(?=&|\\?|$)", "");
if(versionId!=null)
resourcePath = resourcePath.replace("{" + "versionId" + "}" , apiInvoker.toPathValue(versionId));
else
resourcePath = resourcePath.replaceAll("[&?]versionId.*?(?=&|\\?|$)", "");
if(storage!=null)
resourcePath = resourcePath.replace("{" + "storage" + "}" , apiInvoker.toPathValue(storage));
else
resourcePath = resourcePath.replaceAll("[&?]storage.*?(?=&|\\?|$)", "");
if(destStorage!=null)
resourcePath = resourcePath.replace("{" + "destStorage" + "}" , apiInvoker.toPathValue(destStorage));
else
resourcePath = resourcePath.replaceAll("[&?]destStorage.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "PUT", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例8: PutGenerateMultiple
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PutGenerateMultiple
* Generate image with multiple barcodes and put new file on server
* @param name String New filename
* @param format String Format of file
* @param folder String Folder to place file to
* @param file File
* @return SaaSposeResponse
*/
public SaaSposeResponse PutGenerateMultiple (String name, String format, String folder, File file) {
Object postBody = null;
// verify required params are set
if(name == null || file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/barcode/{name}/generateMultiple/?appSid={appSid}&toFormat={toFormat}&folder={folder}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(name!=null)
resourcePath = resourcePath.replace("{" + "name" + "}" , apiInvoker.toPathValue(name));
else
resourcePath = resourcePath.replaceAll("[&?]name.*?(?=&|\\?|$)", "");
if(format!=null)
resourcePath = resourcePath.replace("{" + "format" + "}" , apiInvoker.toPathValue(format));
else
resourcePath = resourcePath.replaceAll("[&?]format.*?(?=&|\\?|$)", "");
if(folder!=null)
resourcePath = resourcePath.replace("{" + "folder" + "}" , apiInvoker.toPathValue(folder));
else
resourcePath = resourcePath.replaceAll("[&?]folder.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "PUT", queryParams, postBody, headerParams, formParams, contentType);
return (SaaSposeResponse) ApiInvoker.deserialize(response, "", SaaSposeResponse.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例9: PostCropImage
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PostCropImage
* Crop image from body
* @param format String Output file format. Valid Formats: Bmp, png, jpg, tiff, psd, gif.
* @param x Integer X position of start point for cropping rectangle
* @param y Integer Y position of start point for cropping rectangle
* @param width Integer Width of cropping rectangle
* @param height Integer Height of cropping rectangle
* @param outPath String Path to updated file, if this is empty, response contains streamed image.
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PostCropImage (String format, Integer x, Integer y, Integer width, Integer height, String outPath, File file) {
Object postBody = null;
// verify required params are set
if(format == null || x == null || y == null || width == null || height == null || file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/imaging/crop/?appSid={appSid}&toFormat={toFormat}&x={x}&y={y}&width={width}&height={height}&outPath={outPath}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(format!=null)
resourcePath = resourcePath.replace("{" + "format" + "}" , apiInvoker.toPathValue(format));
else
resourcePath = resourcePath.replaceAll("[&?]format.*?(?=&|\\?|$)", "");
if(x!=null)
resourcePath = resourcePath.replace("{" + "x" + "}" , apiInvoker.toPathValue(x));
else
resourcePath = resourcePath.replaceAll("[&?]x.*?(?=&|\\?|$)", "");
if(y!=null)
resourcePath = resourcePath.replace("{" + "y" + "}" , apiInvoker.toPathValue(y));
else
resourcePath = resourcePath.replaceAll("[&?]y.*?(?=&|\\?|$)", "");
if(width!=null)
resourcePath = resourcePath.replace("{" + "width" + "}" , apiInvoker.toPathValue(width));
else
resourcePath = resourcePath.replaceAll("[&?]width.*?(?=&|\\?|$)", "");
if(height!=null)
resourcePath = resourcePath.replace("{" + "height" + "}" , apiInvoker.toPathValue(height));
else
resourcePath = resourcePath.replaceAll("[&?]height.*?(?=&|\\?|$)", "");
if(outPath!=null)
resourcePath = resourcePath.replace("{" + "outPath" + "}" , apiInvoker.toPathValue(outPath));
else
resourcePath = resourcePath.replaceAll("[&?]outPath.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "POST", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例10: PostOcrFromUrlOrContent
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PostOcrFromUrlOrContent
* Recognize image text from some url if provided or from the request body content, language can be selected, default dictionaries can be used for correction.
* @param url String The image file url.
* @param language String Language of the document.
* @param useDefaultDictionaries Boolean Use default dictionaries for result correction.
* @param file File
* @return OCRResponse
*/
public OCRResponse PostOcrFromUrlOrContent (String url, String language, Boolean useDefaultDictionaries, File file) {
Object postBody = null;
// create path and map variables
String resourcePath = "/ocr/recognize/?appSid={appSid}&url={url}&language={language}&useDefaultDictionaries={useDefaultDictionaries}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(url!=null)
resourcePath = resourcePath.replace("{" + "url" + "}" , apiInvoker.toPathValue(url));
else
resourcePath = resourcePath.replaceAll("[&?]url.*?(?=&|\\?|$)", "");
if(language!=null)
resourcePath = resourcePath.replace("{" + "language" + "}" , apiInvoker.toPathValue(language));
else
resourcePath = resourcePath.replaceAll("[&?]language.*?(?=&|\\?|$)", "");
if(useDefaultDictionaries!=null)
resourcePath = resourcePath.replace("{" + "useDefaultDictionaries" + "}" , apiInvoker.toPathValue(useDefaultDictionaries));
else
resourcePath = resourcePath.replaceAll("[&?]useDefaultDictionaries.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(file == null){
contentType = "application/json";
}else{
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "POST", queryParams, postBody, headerParams, formParams, contentType);
return (OCRResponse) ApiInvoker.deserialize(response, "", OCRResponse.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例11: PutExecuteTemplateOnline
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PutExecuteTemplateOnline
* Populate document template with data online.
* @param cleanup String Clean up options.
* @param useWholeParagraphAsRegion Boolean Gets or sets a value indicating whether paragraph with TableStart or TableEnd field should be fully included into mail merge region or particular range between TableStart and TableEnd fields. The default value is true.
* @param withRegions Boolean Merge with regions or not. True by default
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PutExecuteTemplateOnline (String cleanup, Boolean useWholeParagraphAsRegion, Boolean withRegions, File file) {
Object postBody = null;
// verify required params are set
if(file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/words/executeTemplate/?appSid={appSid}&cleanup={cleanup}&useWholeParagraphAsRegion={useWholeParagraphAsRegion}&withRegions={withRegions}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(cleanup!=null)
resourcePath = resourcePath.replace("{" + "cleanup" + "}" , apiInvoker.toPathValue(cleanup));
else
resourcePath = resourcePath.replaceAll("[&?]cleanup.*?(?=&|\\?|$)", "");
if(useWholeParagraphAsRegion!=null)
resourcePath = resourcePath.replace("{" + "useWholeParagraphAsRegion" + "}" , apiInvoker.toPathValue(useWholeParagraphAsRegion));
else
resourcePath = resourcePath.replaceAll("[&?]useWholeParagraphAsRegion.*?(?=&|\\?|$)", "");
if(withRegions!=null)
resourcePath = resourcePath.replace("{" + "withRegions" + "}" , apiInvoker.toPathValue(withRegions));
else
resourcePath = resourcePath.replaceAll("[&?]withRegions.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "PUT", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例12: PostImagePsd
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PostImagePsd
* Update parameters of psd image.
* @param channelsCount Integer Count of channels.
* @param compressionMethod String Compression method.
* @param fromScratch Boolean Specifies where additional parameters we do not support should be taken from. If this is true � they will be taken from default values for standard image, if it is false � they will be saved from current image. Default is false.
* @param outPath String Path to updated file, if this is empty, response contains streamed image.
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PostImagePsd (Integer channelsCount, String compressionMethod, Boolean fromScratch, String outPath, File file) {
Object postBody = null;
// verify required params are set
if(file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/imaging/psd/?appSid={appSid}&channelsCount={channelsCount}&compressionMethod={compressionMethod}&fromScratch={fromScratch}&outPath={outPath}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(channelsCount!=null)
resourcePath = resourcePath.replace("{" + "channelsCount" + "}" , apiInvoker.toPathValue(channelsCount));
else
resourcePath = resourcePath.replaceAll("[&?]channelsCount.*?(?=&|\\?|$)", "");
if(compressionMethod!=null)
resourcePath = resourcePath.replace("{" + "compressionMethod" + "}" , apiInvoker.toPathValue(compressionMethod));
else
resourcePath = resourcePath.replaceAll("[&?]compressionMethod.*?(?=&|\\?|$)", "");
if(fromScratch!=null)
resourcePath = resourcePath.replace("{" + "fromScratch" + "}" , apiInvoker.toPathValue(fromScratch));
else
resourcePath = resourcePath.replaceAll("[&?]fromScratch.*?(?=&|\\?|$)", "");
if(outPath!=null)
resourcePath = resourcePath.replace("{" + "outPath" + "}" , apiInvoker.toPathValue(outPath));
else
resourcePath = resourcePath.replaceAll("[&?]outPath.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "POST", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例13: PostImageJpg
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PostImageJpg
* Update parameters of jpg image.
* @param quality Integer Quality of image. From 0 to 100. Default is 75
* @param compressionType String Compression type.
* @param fromScratch Boolean Specifies where additional parameters we do not support should be taken from. If this is true � they will be taken from default values for standard image, if it is false � they will be saved from current image. Default is false.
* @param outPath String Path to updated file, if this is empty, response contains streamed image.
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PostImageJpg (Integer quality, String compressionType, Boolean fromScratch, String outPath, File file) {
Object postBody = null;
// verify required params are set
if(file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/imaging/jpg/?appSid={appSid}&quality={quality}&compressionType={compressionType}&fromScratch={fromScratch}&outPath={outPath}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(quality!=null)
resourcePath = resourcePath.replace("{" + "quality" + "}" , apiInvoker.toPathValue(quality));
else
resourcePath = resourcePath.replaceAll("[&?]quality.*?(?=&|\\?|$)", "");
if(compressionType!=null)
resourcePath = resourcePath.replace("{" + "compressionType" + "}" , apiInvoker.toPathValue(compressionType));
else
resourcePath = resourcePath.replaceAll("[&?]compressionType.*?(?=&|\\?|$)", "");
if(fromScratch!=null)
resourcePath = resourcePath.replace("{" + "fromScratch" + "}" , apiInvoker.toPathValue(fromScratch));
else
resourcePath = resourcePath.replaceAll("[&?]fromScratch.*?(?=&|\\?|$)", "");
if(outPath!=null)
resourcePath = resourcePath.replace("{" + "outPath" + "}" , apiInvoker.toPathValue(outPath));
else
resourcePath = resourcePath.replaceAll("[&?]outPath.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "POST", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}
示例14: nlpSegmentationTokenizeGet
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* Tokenize\n
* Tokenize an input text.\n
* @param inputFile input text\n\n**Either `input` or `inputFile` is required**\n
* @param input input text\n\n**Either `input` or `inputFile` is required**\n
* @param lang Language code of the input ([details](#description_langage_code_values))
* @param profile Profile id\n
* @param callback Javascript callback function name for JSONP Support\n
* @return SegmentationTokenizeResponse
*/
public SegmentationTokenizeResponse nlpSegmentationTokenizeGet (File inputFile, String input, String lang, Integer profile, String callback) throws ApiException {
Object postBody = null;
// verify the required parameter 'lang' is set
if (lang == null) {
throw new ApiException(400, "Missing the required parameter 'lang' when calling nlpSegmentationTokenizeGet");
}
// create path and map variables
String path = "/nlp/segmentation/tokenize".replaceAll("\\{format\\}","json");
// query params
Map<String, Object> queryParams = new HashMap<String, Object>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if (input != null)
queryParams.put("input", apiClient.parameterToString(input));
if (lang != null)
queryParams.put("lang", apiClient.parameterToString(lang));
if (profile != null)
queryParams.put("profile", apiClient.parameterToString(profile));
if (callback != null)
queryParams.put("callback", apiClient.parameterToString(callback));
final String[] accepts = {
"application/json"
};
final String accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {
"multipart/form-data", "application/x-www-form-urlencoded", "*/*"
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false;
FormDataMultiPart mp = new FormDataMultiPart();
if (inputFile != null) {
hasFields = true;
mp.field("inputFile", inputFile.getName());
mp.bodyPart(new FileDataBodyPart("inputFile", inputFile, MediaType.MULTIPART_FORM_DATA_TYPE));
}
if(hasFields)
postBody = mp;
}
else {
}
try {
String[] authNames = new String[] { "accessToken", "apiKey" };
ClientResponse response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
if(response != null){
return (SegmentationTokenizeResponse) apiClient.deserialize(response, "", SegmentationTokenizeResponse.class);
}
else {
return null;
}
} catch (ApiException ex) {
throw ex;
}
}
示例15: PutSlidesConvert
import com.sun.jersey.multipart.FormDataMultiPart; //導入方法依賴的package包/類
/**
* PutSlidesConvert
* Convert presentation from request content to format specified.
* @param password String The document password.
* @param format String The format.
* @param outPath String Path to save result
* @param file File
* @return ResponseMessage
*/
public ResponseMessage PutSlidesConvert (String password, String format, String outPath, File file) {
Object postBody = null;
// verify required params are set
if(file == null ) {
throw new ApiException(400, "missing required params");
}
// create path and map variables
String resourcePath = "/slides/convert/?appSid={appSid}&password={password}&toFormat={toFormat}&outPath={outPath}";
resourcePath = resourcePath.replaceAll("\\*", "").replace("&", "&").replace("/?", "?").replace("toFormat={toFormat}", "format={format}");
// query params
Map<String, String> queryParams = new HashMap<String, String>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> formParams = new HashMap<String, String>();
if(password!=null)
resourcePath = resourcePath.replace("{" + "password" + "}" , apiInvoker.toPathValue(password));
else
resourcePath = resourcePath.replaceAll("[&?]password.*?(?=&|\\?|$)", "");
if(format!=null)
resourcePath = resourcePath.replace("{" + "format" + "}" , apiInvoker.toPathValue(format));
else
resourcePath = resourcePath.replaceAll("[&?]format.*?(?=&|\\?|$)", "");
if(outPath!=null)
resourcePath = resourcePath.replace("{" + "outPath" + "}" , apiInvoker.toPathValue(outPath));
else
resourcePath = resourcePath.replaceAll("[&?]outPath.*?(?=&|\\?|$)", "");
String[] contentTypes = {
"multipart/form-data"};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
postBody = mp;
}
try {
response = apiInvoker.invokeAPI(basePath, resourcePath, "PUT", queryParams, postBody, headerParams, formParams, contentType);
return (ResponseMessage) ApiInvoker.deserialize(response, "", ResponseMessage.class);
} catch (ApiException ex) {
if(ex.getCode() == 404) {
throw new ApiException(404, "");
}
else {
throw ex;
}
}
}