c语言sscanf函数的用法是什么
296
2022-09-05
.netcore vues实现https下载
[HttpGet("ExportPolicy")] public FileStreamResult ExportPolicy(string id) { var data = service.ExportPolicy(id); Stream stream = new MemoryStream(data.Data); return File(stream, "application/x-compressed"); }
RequestModel
public RequestModel
private byte[] GetFileByHttps(string url) { try { byte[] bytes = null; if (!string.IsNullOrEmpty(url)) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11; WebClient webClient = new WebClient(); webClient.Headers.Add(HttpRequestHeader.UserAgent, "Other"); webClient.Headers.Add(HttpRequestHeader.Accept, "application/x-compressed"); bytes = webClient.DownloadData(url); } return bytes; } catch (Exception ex) { loggerHelper.Error("网闸导出规则列表失败", ex); throw ex; } }
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true;
vue:
export function ExportPolicy(data) { return request({ url: publicConst.prefixSoc + '/GatekeeperSynchronize/ExportPolicy', method: 'get', timeout: timeout, params: { id: data }, responseType: 'blob' })}
async exportFile() { this.$confirm('您确?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'info' }).then(() => { this.loading = true ExportPolicy(this.id).then(res => { if (res.size > 0 && res !== null) { var name = 'policy' + '.tgz' download(res, name) this.$message.success('数据导出成功') this.loading = false } else { this.$message.success('数据导出失败') this.loading = false } }).catch(error => { this.$message.error(error) this.loading = false }) }) },
export function download(data, fileName) { if (!data) { return } const blob = new Blob([data], { type: 'application/x-compressed' }) if ('download' in document.createElement('a')) { const url = window.URL.createObjectURL(blob) const link = document.createElement('a') link.style.display = 'none' link.href = url link.setAttribute('download', fileName) document.body.appendChild(link) link.click() document.body.removeChild(link) window.URL.revokeObjectURL(url) } else { // IE 10+ window.navigator.msSaveBlob(blob, fileName) }}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~