Java servlet cuts off file extension -
i'm attempting serve local or proxy files via java application.
with this
@responsebody @requestmapping(value = "/file/{file}", method = requestmethod.get) public void doget(httpservletrequest request, httpservletresponse response,@pathvariable("file") string f) throws ioexception { string filename = urldecoder.decode(f, "utf-8"); file file = new file("resources/files/", filename); response.setheader("content-type", "video/mp4"); response.setheader("content-length", string.valueof(file.length())); response.setheader("content-disposition", "inline; filename=\"" + file.getname() + "\""); files.copy(file.topath(), response.getoutputstream()); }
with example url such
example.com/file/out2kp2_1.mp4
i'm getting error:
problem accessing /file/out2kp2_1.mp4. reason:
resources\files\out2kp2_1 caused by:
java.nio.file.nosuchfileexception: resources\files\out2kp2_1 @ sun.nio.fs.windowsexception.translatetoioexception(windowsexception.java:79)
if add trailing / url , requestmapping, works, on ios , few other places video player doesn't seem loading file trailing slash doesn't suit purposes.
any appriciated.
thanks mark down. take didn't know answer!?
it's problem spring, have add :.+ file url variable
i.e. @requestmapping(value = "/file/{file:.+}", method = requestmethod.get)
Comments
Post a Comment