亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 node-red. 中下載 tar 文件?

如何在 node-red. 中下載 tar 文件?

MMMHUHU 2023-04-27 16:13:13
我正在嘗試下載 node-red 中的 tar 文件。以下是我下載文件的 JavaScript 代碼。downloadTar(sendObj).then(res => {        var bytes = new Uint8Array(byte); // pass your byte response to this constructor        var blob = new Blob([bytes], {type: "application/tar"});        var link = document.createElement('a');        link.href = window.URL.createObjectURL(blob);        var fileName = 'genome.tar';        link.download = fileName;        link.click();});function downloadTar(data) {    return new Promise((resolve, reject) => {        $.ajax({            url: nodeRedDownloadTar,            type: 'POST',            data: data,            success: function (result) {                resolve(result);            }        });    });}以下是我的 Node-Red 流程,我正在讀取文件a single Buffer Object并將其發送到 http 響應然后是我從后端得到的響應。 問題是沒有下載 tar 文件。我不確定我在哪里制造問題。
查看完整描述

1 回答

?
慕雪6442864

TA貢獻1812條經驗 獲得超5個贊

以下流程正常工作,我使用 http-response 節點中的標頭選項將內容類型設置為appplication/x-tar


[

    {

        "id": "6e993a09.f44244",

        "type": "file in",

        "z": "1c834717.22be01",

        "name": "",

        "filename": "/home/pi/test.tar",

        "format": "",

        "chunk": false,

        "sendError": false,

        "encoding": "none",

        "x": 600,

        "y": 580,

        "wires": [

            [

                "6e7d5f6f.c9477"

            ]

        ]

    },

    {

        "id": "df49df3b.d325b",

        "type": "http in",

        "z": "1c834717.22be01",

        "name": "",

        "url": "/tar",

        "method": "post",

        "upload": false,

        "swaggerDoc": "",

        "x": 380,

        "y": 580,

        "wires": [

            [

                "6e993a09.f44244"

            ]

        ]

    },

    {

        "id": "6e7d5f6f.c9477",

        "type": "http response",

        "z": "1c834717.22be01",

        "name": "",

        "statusCode": "",

        "headers": {

            "content-type": "application/x-tar"

        },

        "x": 800,

        "y": 580,

        "wires": []

    }

]



查看完整回答
反對 回復 2023-04-27
  • 1 回答
  • 0 關注
  • 181 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號