angular - ngx-filesaver 如何控制文件的保存位置?
问题描述
filesaver 从我的输入文本中保存文件,如下所示:
组件.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);
}
组件.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:”文件夹而不询问我
解决方案
推荐阅读
- scala - 将按键分组的序列展开为未分组序列的列表,并在 Scala 中附加了键
- swift - 如何在 google colab 上创建一个 swift notebook
- java - JAVA jframe.remove(panel) 无法按预期工作
- visual-studio-2017 - 在 WiX 3.11 / Visual Studio 2017 上自定义 WixUI_Minimal
- javascript - React 构建错误:模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):
- typescript - 使用 TypeScript 编译 Vue 时出错
- sql - SQL Server 存储过程 - 插入语法错误
- mysql - SQL 查询返回 count sale_id = 4 的项目
- r - 使用R从网页中提取表格
- linux - 递归删除 x64 程序集中的文件