I set up an Amazon AWS Linux server instance (EC2) that contains some audio files that I would like to retrieve using a REST protocol web service. The URL for my getAudio function is incorrect for some reason.
@Path("/get/{fileName}") // http://ift.tt/1NkFlhJ}
@GET
@Produces("application/wav")
public Response getAudio(@PathParam("fileName") String fileName) {
ResponseBuilder response = null;
StringBuilder builder = new StringBuilder();
builder.append(AUDIO_PATH).append(fileName).append(".wav");
File file = new File(builder.toString());
response = Response.ok(file);
response.header("Content-Disposition", "attachment; filename=" + fileName + ".wav")
.header("Access-Control-Allow-Origin", "*");
return response.build();
}
AUDIO_PATH is a final String variable that contains the associated path to the created audio files in the Linux instance.
In regards to Glassfish, this is an application server that lets me deploy the web service which consists of this function as well as a few other working functions.
When I run a URL using Glassish which I know is put in correctly, there is a 404 error which says that the URL is not found. I have created a security exception in my Amazon Management console that allows for HTTP protocols.
The URL I'm using to try to access this getAudio function is: http://ift.tt/1Nl0ad9
This port number is 80 since when you add a security exception for HTTP protocol, then that's the port number it says to use. There is also an already created audio file named "hello.wav" in the Linux instance in the /AUDIO_PATH/ path which is what I'm trying to download in the URL.
Also a side note, but I'm running my program with Glassfish from my IntelliJ IDE which also contains a createAudio function with the path: @Path("/create/{fileName}/{text}")
This function works, creating audio based on what the text was that was input, but I can't download the audio from the instance.
Aucun commentaire:
Enregistrer un commentaire