[FIX] some fixes
This commit is contained in:
parent
8b831522dc
commit
9f43ebc782
@ -304,9 +304,11 @@ public class DataResource {
|
|||||||
// logger.info("===================================================");
|
// logger.info("===================================================");
|
||||||
final Data value = getSmall(uuid);
|
final Data value = getSmall(uuid);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
LOGGER.warn("Request data that does not exist : {}", uuid);
|
||||||
return Response.status(404).entity("media NOT FOUND: " + uuid).type("text/plain").build();
|
return Response.status(404).entity("media NOT FOUND: " + uuid).type("text/plain").build();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
LOGGER.warn("Generate stream : {}", uuid);
|
||||||
return buildStream(getFileData(uuid), range,
|
return buildStream(getFileData(uuid), range,
|
||||||
value.mimeType == null ? "application/octet-stream" : value.mimeType);
|
value.mimeType == null ? "application/octet-stream" : value.mimeType);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
@ -478,7 +480,7 @@ public class DataResource {
|
|||||||
to = file.length() - 1;
|
to = file.length() - 1;
|
||||||
}
|
}
|
||||||
final String responseRange = String.format("bytes %d-%d/%d", from, to, file.length());
|
final String responseRange = String.format("bytes %d-%d/%d", from, to, file.length());
|
||||||
// logger.info("responseRange: {}", responseRange);
|
// LOGGER.info("responseRange: {}", responseRange);
|
||||||
try {
|
try {
|
||||||
final RandomAccessFile raf = new RandomAccessFile(file, "r");
|
final RandomAccessFile raf = new RandomAccessFile(file, "r");
|
||||||
raf.seek(from);
|
raf.seek(from);
|
||||||
|
@ -58,5 +58,4 @@ public class MediaStreamer implements StreamingOutput {
|
|||||||
public long getLenth() {
|
public long getLenth() {
|
||||||
return this.length;
|
return this.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ public class WebApplicationExceptionCatcher implements ExceptionMapper<WebApplic
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RestErrorResponse build(final WebApplicationException exception) {
|
private RestErrorResponse build(final WebApplicationException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
return new RestErrorResponse(exception.getResponse().getStatusInfo().toEnum(), "Catch system exception",
|
return new RestErrorResponse(exception.getResponse().getStatusInfo().toEnum(), "Catch system exception",
|
||||||
exception.getMessage());
|
exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@ public class CORSFilter implements ContainerResponseFilter {
|
|||||||
// System.err.println("filter cors ..." + request.toString());
|
// System.err.println("filter cors ..." + request.toString());
|
||||||
|
|
||||||
response.getHeaders().add("Access-Control-Allow-Origin", "*");
|
response.getHeaders().add("Access-Control-Allow-Origin", "*");
|
||||||
|
response.getHeaders().add("Access-Control-Allow-Range", "bytes");
|
||||||
|
response.getHeaders().add("access-control-expose-headers", "range");
|
||||||
response.getHeaders().add("Access-Control-Allow-Headers",
|
response.getHeaders().add("Access-Control-Allow-Headers",
|
||||||
"Origin, content-type, Content-type, Accept, Authorization, mime-type, filename");
|
"Origin, content-type, Content-type, Accept, Authorization, mime-type, filename, Range");
|
||||||
response.getHeaders().add("Access-Control-Allow-Credentials", "true");
|
response.getHeaders().add("Access-Control-Allow-Credentials", "true");
|
||||||
response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD");
|
response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD");
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,9 @@ public class DataTools {
|
|||||||
if (data.contentEquals("null")) {
|
if (data.contentEquals("null")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (data.contentEquals("undefined")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user