我尝试使用 NEST.JS 和 MULTER 制作一个简单的文件上传 REST 接口 - 但它不起作用。我能够将二进制文件debug.log发布到 URL,并且看到“Hello undefined”消息,但上传的文件既不是在给定文件夹上传中创建的,也不是因为扩展名不正确而被拒绝 - 根据文件过滤器。但是,没有显示任何异常或错误。
为什么 multer 不工作?为什么@Uploadedfile() 文件显示为未定义?
谢谢
import { Controller, Post, Request, UseInterceptors, FileInterceptor, UploadedFile, HttpCode, HttpException, HttpStatus } from '@nestjs/common';
import { diskStorage, File } from 'multer';
const path = require('path');
const myStorage = diskStorage({
destination: function (req, file, callback) {
callback(null, './uploads/');
},
limits: { fileSize: 1000000 },
fileFilter: function (req, file, cb) {
const extension = path.extname(file.originalname).toLowerCase()
const mimetyp = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 JavaFX 标签和组,通过鼠标拖动将它们移动到屏幕上。新节点从某些线程添加到动画组中。然而,有时我会突然看到以下异常 - 我假设,当某些节点重叠时。但我不知道问题是什么......因为我的代码不涉及。有谁知道这个异常和根本原因(使用JDK 1.8.0.-112)?谢谢
'JavaFX Application Thread' lambda$main$68 - Thread[JavaFX Application Thread,5,main] threw an uncaught exception: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:418) ~[?:1.8.0_112]
at java.util.ArrayList.get(ArrayList.java:431) ~[?:1.8.0_112]
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89) ~[jfxrt.jar:?]
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306) ~[jfxrt.jar:?]
at javafx.scene.Parent.updateCachedBounds(Parent.java:1591) ~[jfxrt.jar:?]
at javafx.scene.Parent.recomputeBounds(Parent.java:1535) ~[jfxrt.jar:?]
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) ~[jfxrt.jar:?]
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078) ~[jfxrt.jar:?]
at javafx.scene.Node.updateGeomBounds(Node.java:3579) ~[jfxrt.jar:?]
at javafx.scene.Node.getGeomBounds(Node.java:3532) ~[jfxrt.jar:?]
at javafx.scene.Node.getLocalBounds(Node.java:3480) ~[jfxrt.jar:?]
at javafx.scene.Node.updateTxBounds(Node.java:3643) ~[jfxrt.jar:?]
at javafx.scene.Node.getTransformedBounds(Node.java:3426) ~[jfxrt.jar:?]
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732) ~[jfxrt.jar:?]
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596) ~[jfxrt.jar:?]
at javafx.scene.Parent.recomputeBounds(Parent.java:1535) ~[jfxrt.jar:?]
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388) ~[jfxrt.jar:?]
at javafx.scene.Node.updateGeomBounds(Node.java:3579) ~[jfxrt.jar:?]
at javafx.scene.Node.getGeomBounds(Node.java:3532) ~[jfxrt.jar:?]
at javafx.scene.Node.getLocalBounds(Node.java:3480) ~[jfxrt.jar:?] …Run Code Online (Sandbox Code Playgroud) 我想根据节点的宽度订购随机数量的节点。但是我无法计算宽度的总和(使用它们的属性),我有以下示例代码-我无法得知其中一个属性的变化:
@Override
public void start(Stage arg0) throws Exception {
List<SimpleIntegerProperty> l = IntStream.range(0, 10)
.mapToObj(SimpleIntegerProperty::new)
.collect(Collectors.toList());
ObservableList<IntegerProperty> widthAr = FXCollections.observableArrayList();
widthAr.addAll(l);
IntegerBinding nextheight = Bindings.createIntegerBinding(() -> widthAr.stream()
.mapToInt(IntegerProperty::get)
.sum(), widthAr);
nextheight.addListener((v, o, n) -> System.out.println("New value: " + v.getValue()));
//Now change randomly one of the IntegerProperties
ScheduledExecutorService tfsqueryScheduler = Executors.newScheduledThreadPool(1);
tfsqueryScheduler.scheduleAtFixedRate(() -> {
System.out.println("Changing");
int i = (int) Math.round(Math.random() * 9.4);
SimpleIntegerProperty v = l.get(i);
v.set(0);
}, 0, 3, TimeUnit.SECONDS);
System.out.println("Start...");
}
Run Code Online (Sandbox Code Playgroud)
再也不会调用nextheight.addListener :( ...有什么想法吗?谢谢!
javafx ×2
binding ×1
exception ×1
file-upload ×1
java ×1
multer ×1
nestjs ×1
properties ×1
rest ×1