Hi,
Im fairly new to this jsp stuff and im having a few problems POSTING an audio file from a form to a certain url
I know that the audio file has to be changed to binary before its posted
This is the main body of my code that im trying. Any help appreciated "SpeechToText" is the name of my submit button
if(SpeechToText!=null){ String url = FQDN + "/rest/1/SpeechToText"; HttpClient client = new HttpClient(); PostMethod method = new PostMethod(url); method.setQueryString("access_token=" + accessToken); method.addRequestHeader("Authorization","Bearer " + accessToken); String file = application.getRealPath("/") + "bostonSeltics.wav"; FileInputStream fileinputstream = new FileInputStream(file); int numberBytes = fileinputstream.available(); byte bytearray[] = new byte[numberBytes]; fileinputstream.read(bytearray); for(int i = 0; i < numberBytes; i++){ out.println(bytearray[i]); } //this outputs loads of characters but i dont think they are binary?! method.setRequestBody(fileinputstream); //I thought this would post it for me but it doesnt method.request.getInputStream(url); method.setRequestHeader("Content-Type","audio/wav"); method.addRequestHeader("Accept","application/json"); int statusCode = client.executeMethod(method); if(statusCode > 201) { // success etc