refactor the post multipartfile

This commit is contained in:
fanfuxiaoran 2014-05-04 17:25:22 +08:00
parent 9fc26763bd
commit 24ffcd6925
2 changed files with 58 additions and 51 deletions

View File

@ -134,7 +134,9 @@ public class HttpRequester {
}
Part[] parts = new Part[files.size() + strings.size()];
for (int i = 0; i < files.size(); i++) {
parts[i] = new FilePart(filePartName, files.get(i));
FilePart filePart = new FilePart(filePartName, files.get(i)
.getName(), files.get(i));
parts[i] = filePart;
}
for (int i = 0; i < strings.size(); i++) {
parts[i + files.size()] = new StringPart(stringPartName,
@ -157,14 +159,16 @@ public class HttpRequester {
List<File> files = new LinkedList<File>();
if (multipartFiles != null) {
for (MultipartFile multipartFile : multipartFiles) {
File file = new File("paramFile.txt");
File file = new File(multipartFile.getOriginalFilename());
multipartFile.transferTo(file);
files.add(file);
}
}
return postFiles(headers, url, filePartName, files, stringPartName,
strings);
}
private HttpResponse send(String urlString, String method,

View File

@ -1,49 +1,52 @@
package org.bench4q.share.models.master;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "user")
public class UserModel {
private int id;
private String userName;
private String password;
private byte scope;
@XmlElement
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@XmlElement
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@XmlElement
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@XmlElement
public byte getScope() {
return scope;
}
public void setScope(byte scope) {
this.scope = scope;
}
}
package org.bench4q.share.models.master;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "user")
public class UserModel {
private int id;
private String userName;
private String password;
private byte scope;
public UserModel(){
}
@XmlElement
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@XmlElement
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@XmlElement
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@XmlElement
public byte getScope() {
return scope;
}
public void setScope(byte scope) {
this.scope = scope;
}
}