我想向我的 Blob 文件添加一个文件名,但我真的不知道该怎么做,这是我目前的代码:
onClick() {
var myHeader = new Headers();
myHeader.append('Content-Type', 'text/plain');
fetch(this.props.url, {
method: 'POST',
headers: myHeader,
body: JSON.stringify(this.state.api_arg)
}).then(response => {
const filename = getFileName(response.headers.get('Content-Disposition'))
response.blob().then(myBlob => {
const fileUrl = URL.createObjectURL(myBlob)
console.log(fileUrl)
window.open(fileUrl)
})
})
}
Run Code Online (Sandbox Code Playgroud)
我的文件名存储在一个变量中。
| 归档时间: |
|
| 查看次数: |
20099 次 |
| 最近记录: |