1,-sharp-sharp-sharp problem description
failed to upload large file (test 1.3g), picture can be uploaded successfully
/zuul
related codes
/ / Please paste the code text below (do not replace the code with pictures)
zuul gateway configuration
zuul:
routes:
service-video:
path: /video/**
sensitiveHeaders:
service-id: service-video
sensitiveHeaders:
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
@HystrixCommand(fallbackMethod="uploadFallback")
public String uploadFile(@RequestParam("uploadfile") MultipartFile uploadFile,HttpServletRequest request) throws IOException {
JSONObject response = new JSONObject();
String attachName = request.getParameter("attachName");
String tag = request.getParameter("tag");//
String path = "img";
InputStream stream = uploadFile.getInputStream();
if(StringUtils.isNotEmpty(tag)) {
path = tag;
}
attachName = "[" + CommonUtil.getDataFormat(new Date(), "yyyyMMddHHmmssSSS") + "]" + attachName;
UploadFile ftp = new UploadFile();
boolean flag = ftp.UploadFileToServer(stream,attachName, path);
response.put("success", flag);
response.put("uploadFileName", attachName);
return response.toString();
}
Front end call
$.ajax({
url: server + "/zuul/video/uploadFile",
data: formFile,
type: "Post",
dataType: "json",
cache: false, //
processData: false, //data false
contentType: false, //
xhr: function () {
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
myXhr.upload.addEventListener("progress", function (e) {
console.log("in Download progress");
if (e.lengthComputable) {
var percentComplete = Math.round((e.loaded / e.total) * 100);
console.log(percentComplete);
$("-sharpvideo-progress-width").css("width", percentComplete + "%");
} else {
console.log("Length not computable.");
}
}, false);
}
return myXhr;
},
beforeSend: function () {
$("-sharpvideo-progress").show();
},
complete: function () {
$("-sharpvideo-progress").hide();
},
success: function (result) {
$("-sharpchooceVideo").removeAttr("disabled");
$("-sharpchooceVideo").val("");
if (result.success) {
that.uploadVideoFileshow = true;
$("-sharpuploadVideoPath").val(result.uploadFileName);
} else {
layer.alert("!");
}
},
error: function () {
$("-sharpvideo-progress").hide();
$("-sharpchooceVideo").removeAttr("disabled");
$("-sharpchooceVideo").val("");
layer.alert("!");
}
})
what result do you expect? What is the error message actually seen?
File uploaded successfully. Small files can be uploaded