本文整理了Java中org.apache.http.entity.mime.MultipartEntity.getContentType()
方法的一些代码示例,展示了MultipartEntity.getContentType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultipartEntity.getContentType()
方法的具体详情如下:
包路径:org.apache.http.entity.mime.MultipartEntity
类名称:MultipartEntity
方法名:getContentType
暂无
代码示例来源:origin: stackoverflow.com
public String getBodyContentType()
return entity.getContentType().getValue();
代码示例来源:origin: stackoverflow.com
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
FileBody fileBody = new FileBody(new File(fileName));
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.STRICT);
multipartEntity.addPart("file", fileBody);
connection.setRequestProperty("Content-Type", multipartEntity.getContentType().getValue());
OutputStream out = connection.getOutputStream();
try {
multipartEntity.writeTo(out);
} finally {
out.close();
}
int status = connection.getResponseCode();
...
代码示例来源:origin: stackoverflow.com
MultipartEntity httpMultipart = new MultipartEntity();
String contentType = httpMultipart.getContentType().getValue();
代码示例来源:origin: stackoverflow.com
MultipartEntity reqEntity = new MultipartEntity();
// add your ContentBody fields as normal...
// Now, pull out the contents of everything you've added and set it as the payload
ByteArrayOutputStream bos = new ByteArrayOutputStream((int)reqEntity.getContentLength());
reqEntity.writeTo(bos);
oAuthReq.addPayload(bos.toByteArray());
// Finally, set the Content-type header (with the boundary marker):
Header contentType = reqEntity.getContentType();
oAuthReq.addHeader(contentType.getName(), contentType.getValue());
// Sign and send like normal:
service.signRequest(new Token(oAuthToken, oAuthSecret), oAuthReq);
Response oauthResp = oAuthReq.send();
代码示例来源:origin: com.atlassian.httpclient/atlassian-httpclient-apache-httpcomponents
@Override
public Entity build()
{
try
{
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
apacheMultipartEntity.writeTo(outputStream);
final InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
final Header header = apacheMultipartEntity.getContentType();
final Map<String, String> headers = Maps.newHashMap();
headers.put(header.getName(), header.getValue());
return new MultiPartEntity(headers, inputStream);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: stackoverflow.com
URL url = new URL(baseURL+"/projects/"+projectId+"/CSVUpload?authenticity_token="+URLEncoder.encode(authToken, "UTF-8"));
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
MultipartEntity entity = new MultipartEntity();
entity.addPart("utf8", new StringBody("\u2713", "text/plain", Charset.forName("UTF-8")));
entity.addPart("csv", new FileBody(csvToUpload, "text/csv"));
connection.setRequestProperty("Content-Type", entity.getContentType().getValue());
OutputStream out = connection.getOutputStream();
try {
entity.writeTo(out);
} finally {
out.close();
}
connection.getResponseCode();
代码示例来源:origin: com.github.vatbub/VirustotalPublicV2.0
private void addMultiparts(List<MultiPartEntity> multiParts, HttpURLConnection conn) throws IOException {
MultipartEntity multipartEntity =
new MultipartEntity(HttpMultipartMode.STRICT);
for (MultiPartEntity part : multiParts) {
multipartEntity.addPart(part.getPartName(), part.getEntity());
}
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type",
multipartEntity.getContentType().getValue());
//try to write to the output stream of the connection
OutputStream outStream = conn.getOutputStream();
multipartEntity.writeTo(outStream);
outStream.close();
}
代码示例来源:origin: kdkanishka/Virustotal-Public-API-V2.0-Client
private void addMultiparts(List<MultiPartEntity> multiParts, HttpURLConnection conn) throws IOException {
MultipartEntity multipartEntity =
new MultipartEntity(HttpMultipartMode.STRICT);
for (MultiPartEntity part : multiParts) {
multipartEntity.addPart(part.getPartName(), part.getEntity());
}
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type",
multipartEntity.getContentType().getValue());
//try to write to the output stream of the connection
OutputStream outStream = conn.getOutputStream();
multipartEntity.writeTo(outStream);
outStream.close();
}
代码示例来源:origin: stackoverflow.com
entity.addPart("location", new StringBody(locaity, ContentType.TEXT_PLAIN));
httpcon.addRequestProperty(entity.getContentType().getName(), entity.getContentType().getValue());
代码示例来源:origin: stackoverflow.com
conn.addRequestProperty(reqEntity.getContentType().getName(), reqEntity.getContentType().getValue());
OutputStream os = conn.getOutputStream();
reqEntity.writeTo(os);
代码示例来源:origin: stackoverflow.com
conn.addRequestProperty(reqEntity.getContentType().getName(), reqEntity.getContentType().getValue());
OutputStream os = conn.getOutputStream();
reqEntity.writeTo(os);
代码示例来源:origin: stackoverflow.com
/* You will have done this bit earlier to authorize the user
OAuthService service = new ServiceBuilder().provider(TwitterApi.SSL.class).apiKey("[YOUR API KEY]").apiSecret("[YOUR SECRET]").callback("twitter://callback").build();
Token accessToken = Do you oauth authorization as normal
*/
OAuthRequest request = new OAuthRequest(Verb.POST, "https://upload.twitter.com/1/statuses/update_with_media.json");
MultipartEntity entity = new MultipartEntity();
try {
entity.addPart("status", new StringBody("insert vacuous statement here"));
entity.addPart("media", new FileBody(new File("/path/of/your/image/file")));
ByteArrayOutputStream out = new ByteArrayOutputStream();
entity.writeTo(out);
request.addPayload(out.toByteArray());
request.addHeader(entity.getContentType().getName(), entity.getContentType().getValue());
service.signRequest(accessToken, request);
Response response = request.send();
if (response.isSuccessful()) {
// you're all good
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
代码示例来源:origin: stackoverflow.com
request.addHeader(entity.getContentType().getName(), entity.getContentType().getValue());
代码示例来源:origin: stackoverflow.com
return entity.getContentType().getValue();
代码示例来源:origin: stackoverflow.com
public String getBodyContentType()
return entity.getContentType().getValue();
代码示例来源:origin: stackoverflow.com
public String getBodyContentType()
return entity.getContentType().getValue();
代码示例来源:origin: stackoverflow.com
req.addPayload(out.toByteArray());
req.addBodyParameter("status", "I have uploaded test image on twitter");
req.addHeader(entity.getContentType().getName(), entity.getContentType().getValue());
org.scribe.model.Response response = req.send();
JSONObject json = new JSONObject(response.getBody());
代码示例来源:origin: org.openestate.is24/OpenEstate-IS24-REST-hc42
request.addHeader( requestMultipartEntity.getContentType() );
request.setHeader( "Content-Language", "en-US" );
request.setHeader( "Accept", "application/xml" );
代码示例来源:origin: org.openestate.is24/OpenEstate-IS24-REST-hc42
request.addHeader( requestMultipartEntity.getContentType() );
request.setHeader( "Content-Language", "en-US" );
request.setHeader( "Accept-Charset", "UTF-8" );
代码示例来源:origin: stackoverflow.com
public String getBodyContentType()
return entity.getContentType().getValue();
内容来源于网络,如有侵权,请联系作者删除!