Hi,
I searched for one day how to upload a simple zip file with Restlet and didn't
manage to get it work. So I need some help.
I have an interface :
************************
public interface FileResource {
@Get
public ArrayList<String> getFiles();
@Post
public void upload(Representation fileEntity);
@Delete
public void archiveFile(String filename);
}
****************
I use Android as a client :
*****************
ClientResource clientResource = new ClientResource(BASE_URL + "/files/" +
destUserDir);
FileResource filesResources = clientResource.wrap(FileResource.class);
ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
ChallengeResponse authentication = new ChallengeResponse(scheme, user, pwd);
clientResource.setChallengeResponse(authentication);
filesResources.upload(new FileRepresentation(myzipfile,
MediaType.APPLICATION_ZIP)); //also tried MULTIPART...
*****************
And I'd like to receive on my tomcat servlet :
*****************
public class FilesResource extends ServerResource implements FileResource {
public void upload(Representation entity) {
getLogger().log(Level.INFO, "UPLOADING");
try {
FileItemFactory factory = new DiskFileItemFactory();
RestletFileUpload fileUpload = new RestletFileUpload(factory);
List<FileItem> items = fileUpload.parseRequest(getRequest()); //or
parseRepresentation(entity)
FileItem fileItem = items.get(0);
...
*****************
But I always get this kind of errors :
FileUploadException: the request was rejected because no multipart boundary was
found
or
InvalidContentTypeException: the request doesn't contain a multipart/form-data
or multipart/mixed stream, content type header is application/zip
Thanks for your help !
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2444808