I am sending a file via Ajax like this:
// Get the selected files from the input.
var files = fileSelect.files;
// Create a new FormData object.
var formData = new FormData();
// Add the file to the request.
formData.append('photos[]', files[0], files[0].name);
$.ajax({
type:"POST",
url:"URL,
dataType:"json",
headers : {"cache-control":"no-cache"},
timeout : 12000,
processData: false,
data:{
formdata:formData
}
Now I want to work with the send file in my java class, in a ressource like this:
@PermitAll
@POST
@Path(URL)
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> fileHandler(@FormParam("formdata") File formdata){ }
But accessing the file does not work, @FormParam("formdata") File formdata seems to be wrong (or more things?). I want to get access to this file in my ressource class somehow. What am I doing wrong? Maybe someone knows a better solution for this.