コンテンツ処理ヘッダーが表示されないようです。私はContent-Typeしか見ることができません。しかしそれは私の反応です。角2はファイルのダウンロードからファイル名を取得します
public openAttachment(id: number) {
this.http
.get(`${this.startupService.baseUrl}company/${this.company.companyID}/attachment/${id}`,
{responseType: 'blob', observe: 'response'})
.subscribe(data => {
console.log(data);
const contentDis = data.headers.get('content-disposition');
console.log(contentDis);
const contentType = data.headers.get('content-type');
console.log(contentType);
});
}
は、ここに私のコンソールログのコピーです:
、ここでの応答です:それはあなたのコードの不具合を思えなかった
私の回避策は、サーバー上のMIMEタイプを正しく設定することです。 Angularがこれを検出してファイルを適切に開きますが、ファイル名は元のファイル名ではなくguidです。 –