Mongodb 尝试自动上载文件时出现Curl错误-http没有此类文件

Mongodb 尝试自动上载文件时出现Curl错误-http没有此类文件,mongodb,docker,curl,Mongodb,Docker,Curl,我已经搜索了各种各样的问题,并尝试了不同的curl命令排列,但还没有找到一个合适的,所以发布了这个问题,因为我可能遗漏了一些明显的东西,无法查看 我正在运行一个curl命令来尝试上传一个文件进行解析 S-MBP:project SG$ curl -i -X POST -F "data=@/Users/SG/Desktop/project/mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz" '

我已经搜索了各种各样的问题,并尝试了不同的curl命令排列,但还没有找到一个合适的,所以发布了这个问题,因为我可能遗漏了一些明显的东西,无法查看

我正在运行一个curl命令来尝试上传一个文件进行解析

S-MBP:project SG$ curl -i -X POST -F "data=@/Users/SG/Desktop/project/mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz" 'http://localhost:3030/upload/'
HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Access-Control-Allow-Headers: accept, content-type
Access-Control-Allow-Methods: POST
Access-Control-Allow-Origin: *
Date: Sat, 25 Jul 2020 14:56:05 GMT
Content-Length: 19
Content-Type: text/plain; charset=utf-8

http: no such file
根据之前的答案尝试的一些排列:

curl -i -X POST -F "filename=@/Users/SG/Desktop/project/mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz" http://localhost:3030/upload/

curl -i -X POST -F "filename=@mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz" http://localhost:3030/upload

curl -i -X POST -F filename=@/Users/SG/Desktop/project/mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz http://localhost:3030/upload/

curl -i -X POST -F "filename=@/Users/SG/Desktop/project/mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz" "http://localhost:3030/upload/"
有趣的是,如果我传入一个不存在的文件名,我会得到相同的错误,但如果我将目录名更改为一个不存在的名称,则错误是一个curl(26),这使我认为命令此时对该文件毫不关心。我正在mac电脑上运行这篇文章,如果这不相关的话,我看到一篇文章暗示brew curl可能有问题

我试图瞄准的表单是docker图像的一部分
https://hub.docker.com/repository/docker/simagix/maobi

省略了一些值的表单

<form action="/upload" id="maobi" class="dropzone dz-clickable dz-started">
    <div class="dz-message">
      Drop files here or click to upload.<br>
    </div>
<div class="dz-filename"><span data-dz-name="">mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz</span></div></div></form>

将文件放到此处或单击上载。
mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz
然后我在页面中看到的脚本,我相信是用来上传并解析生成输出的文档的

    <script>
  Dropzone.options.maobi = {
    timeout: 300000,
    init: function() {
      this.on("success", function(file, responseText) {
        blob = new Blob([responseText], { type: 'text/html' }),
        anchor = document.createElement('a');
        filename = file.upload.filename;
        if ((n = filename.indexOf("mdiag-")) == 0 ) {
          n = filename.lastIndexOf(".json")
          filename = filename.substring(0, n) + ".html";
        } else if ((n = filename.lastIndexOf(".json")) > 0 ) {
        //... 
        //...
        } else if ((n = filename.indexOf(".log")) > 0 && (n = filename.lastIndexOf(".gz")) > 0) {
          filename = filename.substring(0, n) + ".html";
        } else if ((n = filename.lastIndexOf(".bson")) > 0 ) {
          filename = filename.substring(0, n) + "-cluster.html";
        }
        anchor.download = filename;
        anchor.href = (window.webkitURL || window.URL).createObjectURL(blob);
        anchor.dataset.downloadurl = ['text/html', anchor.download, anchor.href].join(':');
        anchor.click();
      });
      this.on("error", function(file, responseText) {
        alert(responseText);
      });
    }
  };
</script>

Dropzone.options.maobi={
超时:30万,
init:function(){
this.on(“success”,函数(文件,responseText){
blob=newblob([responseText],{type:'text/html'}),
anchor=document.createElement('a');
filename=file.upload.filename;
如果((n=filename.indexOf(“mdiag-”)==0){
n=filename.lastIndexOf(“.json”)
filename=filename.substring(0,n)+“.html”;
}如果((n=filename.lastIndexOf(“.json”))>0,则为else{
//... 
//...
}如果((n=filename.indexOf(.log))>0&&(n=filename.lastIndexOf(.gz))>0,则为else{
filename=filename.substring(0,n)+“.html”;
}如果((n=filename.lastIndexOf(“.bson”))>0,则为else{
filename=filename.substring(0,n)+“-cluster.html”;
}
anchor.download=文件名;
anchor.href=(window.webkitURL | | window.URL);
anchor.dataset.downloadurl=['text/html',anchor.download,anchor.href].join(':');
anchor.click();
});
this.on(“error”,函数(文件,responseText){
警报(responseText);
});
}
};

在我看来,您没有在正确的表单字段中传递文件

通过查看Dropzone.js文档,似乎正确的字段名是
文件
(因为这是默认的),而不是
数据
文件名
。但完全可以肯定的是,最好在浏览器的devtools中查看网络请求,并查看用于传递文件的POST字段名

curl-i-X POST-F“文件=@/Users/SG/Desktop/project/mongodb-cluster-shard-00-02.lrqcr.mongodb.net_27017-cluster.bson.gz”http://localhost:3030/upload/'

我不会说谎,现在有一个重要的掌心时刻正在发生。非常感谢。