如何解决ngx-filesaver 如何控制文件的保存位置?
filesaver 从我的输入文本中保存文件,如下所示:
Component.ts
constructor(private _httpClient: HttpClient,private _FileSaverService: FileSaverService,private exportAsService: ExportAsService) { }
public text ="";
public fileName: string;
onDown(type: string,fromRemote: boolean) {
const fileName = `save.${type}`;
if (fromRemote) {
this._httpClient.get(`assets/files/demo.${type}`,{
observe: 'response',responseType: 'blob'
}).subscribe(res => {
this._FileSaverService.save(res.body,fileName);
});
return;
}
const fileType = this._FileSaverService.genType(fileName);
const txtBlob = new Blob([this.text],{ type: fileType });
this._FileSaverService.save(txtBlob,fileName);
}
Component.html
<div class="form-outline" id="mytable">
<textarea [(ngModel)]="text" class="form-control" id="textAreaExample2" rows="15" placeholder="Write a Test Case"></textarea>
</div>
<label>Your Test: </label>
<div class="row" id='display'>
{{text}}
</div>
<button (click)="onDown('robot',false)" type="button" class="btn btn-success float-right">Add</button>
我想知道是否有可能在我点击添加按钮时控制文件的确切存储位置,而无需询问我下载文件的位置
例如,当我单击添加按钮时,我希望将文件下载到“D:”文件夹,而无需询问我
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。