Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Safari下载zip文件为;“未知”;获取时(使用polyfill)_Javascript_Go_Safari_Zip - Fatal编程技术网

Javascript Safari下载zip文件为;“未知”;获取时(使用polyfill)

Javascript Safari下载zip文件为;“未知”;获取时(使用polyfill),javascript,go,safari,zip,Javascript,Go,Safari,Zip,我在服务器端(golang snippet)设置了这些标题,可以在不同的文件夹中压缩16个文件,这些标题在chrome和ff中都很好地工作,但在safari中不起作用。下面是Javascript代码 .... c.Response().Header().Set("Pragma", "public") c.Response().Header().Set("Expires", "0") c.Response().Header().Set("Cache-Control", "must

我在服务器端(golang snippet)设置了这些标题,可以在不同的文件夹中压缩16个文件,这些标题在chrome和ff中都很好地工作,但在safari中不起作用。下面是Javascript代码

.... 
c.Response().Header().Set("Pragma", "public")
    c.Response().Header().Set("Expires", "0")
    c.Response().Header().Set("Cache-Control", "must-revalidate, post-check=0, pre-check=0")
    c.Response().Header().Set("Cache-Control", "public")
    c.Response().Header().Set("Content-Description", "File Transfer")
    c.Response().Header().Set("Content-type", "application/octet-stream")
    c.Response().Header().Set("Content-Transfer-Encoding", "binary")
    c.Response().Header().Set("Content-Lengthg", "177998")
    // header("Content-Length: ".filesize($filepath.$filename));
    filename := "launchaco.zip"
    // c.Response().Header().Set("Content-Type", "application/file")
    c.Response().Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))

    zw := zip.NewWriter(c.Response())

    header := &zip.FileHeader{
        Name:         "index.html",
        Method:       zip.Store,
        ModifiedTime: uint16(time.Now().UnixNano()),
        ModifiedDate: uint16(time.Now().UnixNano()),
    }
....
Javascript

fetch(document.location.origin + "/SECRET_ENDPOINT?s=" + encodeURIComponent(JSON.stringify(localStorage.getItem('structured-elm-todo-state'))))
    .then(function(response) {
        return response.blob();
    }).then(function(blob) {
        saveAs(blob, "download.zip");
        setTimeout(function() {
            var popup = document.getElementById("downloaded-popup");
            popup.className = "downloader-popup downloader-popup__active"
        }, 1000);
    });

如果有人关心您使用的saveAs()库,这里是实际的生产站点?这个:?不确定这是否是原因,但这里有一个输入错误:
内容长度
。另外,您是否尝试将
内容类型设置为
应用程序/zip