惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Jina AI
Jina AI
WordPress大学
WordPress大学
Recent Announcements
Recent Announcements
G
Google Developers Blog
I
InfoQ
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Check Point Blog
J
Java Code Geeks
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
量子位
A
About on SuperTechFans
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - 晨光静默

centos 命令 nginx记录 html select qq作文 mfc开启控制台打印日记 mfc右键菜单(包括系统托盘菜单)弹窗后如何消失 angular单页应用点击button自动刷新页面 setTimeout中调用angular的作用域生效 mfc模态对话框和非模态对话框注意点 c/c++元转分的bug c/c++中的崩溃代码片段 查看网络端口连接情况 win7x64安装python运行报错:api-ms-win-crt-runtime-|1-1-0.dll SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes qt导入头文件报错 python记录 (转)Curl命令详解 开箱即用的clogger 异步重叠IO linux xshell 命令上传下载文件 png转CBitmap
curl用到的一些命令
晨光静默 · 2026-06-03 · via 博客园 - 晨光静默

一、curl上传文件

如何服务器是专网不允许内网访问,但可以访问公网,那可以搭建个公网映射,然后用下面命令把服务器的日记文件传输到本地开发电脑。

hfs.exe工具测试可以上传
curl -X POST "http://192.168.246.1:8088/360/" -F "file=@ver.ini"
curl -X POST "http://xxx.domain/360/" -F "file=@rfd.txt"

同时也可以用springboot写个接收文件上传的服务:
curl -X POST "http://xxx.domain/bocly/upload" -F "file=@rfd.txt"
curl -X POST "http://xxx.domain/bocly/upload" -F "file=@info-2026-06-03.log"

    @PostMapping(value = "upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public Map<String, Object> uploadFile(@RequestParam("file") MultipartFile file) {
        Map<String, Object> out = new LinkedHashMap<>(3);
        if (file == null || file.isEmpty()) {
            out.put("code", CODE_ERR);
            out.put("msg", "上传文件不能为空");
            return out;
        }

        String originalName = file.getOriginalFilename();
        if (StringUtils.isBlank(originalName)) {
            out.put("code", CODE_ERR);
            out.put("msg", "文件名无效");
            return out;
        }

        String safeName = Paths.get(originalName).getFileName().toString();
        if (StringUtils.isBlank(safeName) || safeName.contains("..")) {
            out.put("code", CODE_ERR);
            out.put("msg", "文件名无效");
            return out;
        }

        try {
            Path uploadDir = Paths.get(UPLOAD_DIR).toAbsolutePath().normalize();
            Files.createDirectories(uploadDir);
            Path target = uploadDir.resolve(safeName).normalize();
            if (!target.startsWith(uploadDir)) {
                out.put("code", CODE_ERR);
                out.put("msg", "文件名无效");
                return out;
            }
            file.transferTo(target.toFile());
            log.info("文件上传成功: name={}, size={}, path={}", safeName, file.getSize(), target);
            out.put("code", CODE_OK);
            out.put("msg", "上传成功");
            out.put("path", target.toString());
            out.put("filename", safeName);
            return out;
        } catch (IOException e) {
            log.error("文件上传失败: name={}", safeName, e);
            out.put("code", CODE_ERR);
            out.put("msg", "文件保存失败: " + e.getMessage());
            return out;
        }
    }

二、curl post json报文从文件读取

curl -X POST -H "Content-Type: application/json" -d @rfd.txt http://127.0.0.1:8080/bocly/refund