Javascript 上传文件到谷歌云存储使用链接

Javascript 上传文件到谷歌云存储使用链接,javascript,node.js,google-cloud-storage,Javascript,Node.js,Google Cloud Storage,我试图从链接上传一个文件到地面军事系统,但我不知道怎么做 这是我的密码 app.post("/uploads", upload.any("tmparr"), async (req, res) => { await storage .bucket(bucketName) .upload( "https://lalalai.s3-us-west-2.amazonaws.com/media/split/9f6f7c

我试图从链接上传一个文件到地面军事系统,但我不知道怎么做

这是我的密码

app.post("/uploads", upload.any("tmparr"), async (req, res) => {
  await storage
    .bucket(bucketName)
    .upload(
      "https://lalalai.s3-us-west-2.amazonaws.com/media/split/9f6f7cb6-43b2-45ee-bec7-16ae2f7214b5/vocals",
      {
        gzip: true,
        metadata: {
          cacheControl: "public, max-age=31536000",
        },
      }
    );
  console.log("done");
}); 
我犯了这样的错误

(node:56016) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat 'D:\reactjs\crud-mern\server\https:\lalalai.s3-us-west-2.amazonaws.com\media\split\9f6f7cb6-43b2-45ee-bec7-16ae2f7214b5\vocals'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:56016) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This 
error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:56016) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the 
Node.js process with a non-zero exit code.

有人能帮我修一下吗?谢谢

云存储不接受指向文件的url链接作为上传参数,正如您在for
bucket.upload()中看到的,它需要:

要上载到bucket的文件的完全限定路径

您得到的错误消息就是证明,因为它试图将URL解释为本地系统上的路径


因此,为了实现这一点,您必须首先从链接下载所述文件,然后调用GCS SDK并将其上载。

云存储不接受指向文件的url链接作为上载参数,正如您在for
bucket.upload()中看到的,它需要:

要上载到bucket的文件的完全限定路径

您得到的错误消息就是证明,因为它试图将URL解释为本地系统上的路径


因此,为了实现这一点,您必须首先从链接下载所述文件,然后调用GCS SDK并上传。

如果您查看路径,它试图从您的本地机器获取文件。啊,我知道,但是如何从链接获取文件?使用nodejs获取文件,然后将其放在gcscan上。您能举个例子吗?我是javascript@MehdiBenmohayes新手当然,欢迎来到javascript世界,这里有一个例子:如果你看路径,它试图从你的本地机器抓取文件啊,我知道,但是如何从链接抓取文件?用nodejs获取文件,然后把它放在gcscan上。你给我一个例子吗?我是javascript新手@MehdiBenmohayes当然,欢迎来到javascript世界,这里有一个例子:@ubigoreng你成功了吗?@ubigoreng你成功了吗?