从链接javascript下载数据

问题描述

我有输入type ='text',用户将像这样向用户提供要下载的google文档的超链接

“ https://docs.google.com/spreadsheets/d/1w_qYEgD5w-xIrnMpRMmeUycZBJiAfo4zxlVTkXb8LU4/export?gid=1865948320&format=csv”

当我将此字符串作为href传递给带有下载参数的链接时,它会提示另存为窗口并以csv格式保存文件。如果您点击上面提到的链接,它将触发文件下载。我的目标是在没有“另存为”窗口的情况下在客户端保存数据并使用csv数据。关于如何实施此建议?感谢任何帮助。

解决方法

实际上,在客户端,我有一个输入,用户在该文件上提供具有预定义csv格式的特定文档上的docs.google链接,然后将此链接发送到我的本地服务器上。在本地服务器上,我发出axios get请求,功能看起来像这样

// Request from client where I send url link
app.post("/upload",(req,res) => {
  // Handle get request with link provided from client/front
  axios(req.body.payload,{ method: "GET" })
    .then((response) => {
      res.status(200);
      // Data represents string of characters that I send back to client and 
      // and in my case populate table
      res.json({ file: response.data });
    })
    .catch((error) => {
      res.status(404);
      res.send(error);
    });
});