gpt4 book ai didi

spring-boot - Spring Boot multipart 文件上传,去除本地服务器副本

转载 作者:行者123 更新时间:2023-12-02 17:09:44 32 4
gpt4 key购买 nike

最近在开发rest API,提供上传图片的功能。一切正常,但是我的后端服务器位置被图像副本填满了。看起来 spring 保留了它上传的每张图像的本地副本。是否有任何选项可以禁用本地副本的保存。我快速浏览了文档,发现了以下多部分文件的属性。

# MULTIPART (MultipartProperties)
spring.servlet.multipart.enabled=true # Whether to enable support of
multipart uploads.
spring.servlet.multipart.file-size-threshold=0 # Threshold after which files
are written to disk. Values can use the suffixes "MB" or "KB" to indicate
megabytes or kilobytes, respectively.
spring.servlet.multipart.location= # Intermediate location of uploaded
files.
spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use
the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively.
spring.servlet.multipart.max-request-size=10MB # Max request size. Values
can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes,
respectively.
spring.servlet.multipart.resolve-lazily=false # Whether to resolve the
multipart request lazily at the time of file or parameter access.

我们可以告诉系统复制本地副本的位置,但没有禁用它的选项。你们对此有什么建议吗?我们是否需要有一个单独的程序来清除这些本地镜像副本并节省空间?

谢谢,凯思

最佳答案

我知道这个主题有点老了,但它是我在 google 搜索中出现的第一个。

今天我遇到了同样的问题。经过一些研究,事实证明 Spring 会自动执行此清理工作。就我而言,清理没有完成,因为我忘记关闭与接收到的文件相关的流。

希望对你有帮助。

关于spring-boot - Spring Boot multipart 文件上传,去除本地服务器副本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49849576/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com