节点。从NodeJS到javaspring框架的js文件上传
我需要一个简单的文件上传(JavaScript
代码示例)从NodeJS
到JavaSpring框架方法,如下所示
任何帮助(方法)都将不胜感激
Spring框架中的Java代码:
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public ResponseEntity<FileJobResultBase> upload(HttpServletRequest httpServletRequest
) throws IOException {
try {
String storageName = httpServletRequest.getHeader("storageName");
String path = httpServletRequest.getHeader("path");
String fileName = httpServletRequest.getHeader("fileName");
String fileType = httpServletRequest.getHeader("fileType");
String context = httpServletRequest.getHeader("context");
String organization = httpServletRequest.getHeader("organization");
byte[] bytes = IOUtils.toByteArray(httpServletRequest.getInputStream());
FileJobResultBase fileJobResultBase = fileManagerService.upload(bytes, storageName, path, fileName, fileType == null ? "unknown" : fileType,authorization,organization, context);
return new ResponseEntity<>(fileJobResultBase, HttpStatus.OK);
} catch (Exception e) {
return exceptionHandling( e);
}
}
当前我的NodeJS
代码(但不好)
module.exports = {
create : function(req, res) {
var file = Object.keys(req.body.file).map(function(value, index) { return [value]; });
var headerSignature = APISigningService.getHeaderSignature();
}
共 (0) 个答案