本文整理汇总了Java中com.mashape.unirest.request.HttpRequestWithBody.field方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestWithBody.field方法的具体用法?Java HttpRequestWithBody.field怎么用?Java HttpRequestWithBody.field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mashape.unirest.request.HttpRequestWithBody
的用法示例。
在下文中一共展示了HttpRequestWithBody.field方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fieldFileOrElse
import com.mashape.unirest.request.HttpRequestWithBody; //导入方法依赖的package包/类
private MultipartBody fieldFileOrElse(HttpRequestWithBody post,
MultipartBody field,
Map.Entry<String, Object> entry,
Object value) {
if (value instanceof File) {
if (field != null) field.field(entry.getKey(), (File) value);
else field = post.field(entry.getKey(), (File) value);
} else if (value instanceof MultipartFile) {
if (field != null)
field.field(entry.getKey(), (MultipartFile) value);
else field = post.field(entry.getKey(), (MultipartFile) value);
} else {
if (field != null) field.field(entry.getKey(), value);
else field = post.field(entry.getKey(), value);
}
return field;
}
示例2: uploadOne
import com.mashape.unirest.request.HttpRequestWithBody; //导入方法依赖的package包/类
@Test
public void uploadOne() throws IOException {
// Create temp file.
File temp = File.createTempFile("myimage", ".image");
Files.write("Hello world", temp, Charsets.UTF_8);
try {
HttpRequestWithBody post = Unirest.post("http://localhost:4849/upload/image");
post.field("name", "bingoo.txt");
post.field("file", temp);
HttpResponse<String> file = post
.asString();
System.out.println(file.getStatus());
} catch (Exception e) {
e.printStackTrace();
}
temp.delete();
}
示例3: uploadFiles
import com.mashape.unirest.request.HttpRequestWithBody; //导入方法依赖的package包/类
public void uploadFiles(List<File> filepaths, String uploaddir) throws AptlyRestException
{
mLogger.println("upload dir name: " + uploaddir);
try {
HttpRequestWithBody req = Unirest.post(mSite.getUrl() +
"/api/files/" + uploaddir);
req.field("file", filepaths);
JSONObject res = sendRequest(req);
}
catch (AptlyRestException ex) {
mLogger.printf("Failed to upload the packages: %s\n", ex.toString());
throw ex;
}
}
示例4: applyFields
import com.mashape.unirest.request.HttpRequestWithBody; //导入方法依赖的package包/类
@Override
public void applyFields(HttpRequestWithBody request) {
request.field("sessionId", this.sessionId);
}
示例5: applyFields
import com.mashape.unirest.request.HttpRequestWithBody; //导入方法依赖的package包/类
@Override
public void applyFields(HttpRequestWithBody request) {
request.field("roomId", this.roomId);
}
示例6: applyFields
import com.mashape.unirest.request.HttpRequestWithBody; //导入方法依赖的package包/类
@Override
public void applyFields(HttpRequestWithBody request) {
request.field("playerId", this.playerId);
}
示例7: applyFields
import com.mashape.unirest.request.HttpRequestWithBody; //导入方法依赖的package包/类
@Override
public void applyFields(HttpRequestWithBody request) {
request.field("authenticationTicket", authenticationTicket);
}