如果我从后端(Spring-boot)发送图像路径和文件名作为响应,并想通过适当的身份验证以角度下载该文件?

时间:2019-03-11 05:09:08

标签: angular spring-boot

角度代码

this.crmService.getAttachments(complaint_id).subscribe(data => {
    this.imagesArray= data.attachement.images;
    var filesPath=data.attachement.filesPath;
    var fileName=data.attachement.fileName;
    var completePath=filesPath+"\\"+fileName;
    console.log(completePath);
})

现在我们获得了完整的路径,我将这个完整的路径粘贴到浏览器中,它在另一个选项卡中打开了我的图像,但是没有身份验证或隐私。但是我希望通过angular函数来对此进行身份验证。请提供解决方案。

是否有任何重定向方法(302重定向)可以做到这一点?

我的角度认证功能---

getMultipartOptions(){

let token;

if (this.isLoggedIn()) {

  token = StorageService.get("access_token");

  var accessTime = new Date().getTime();

  StorageService.set("last_access_application", JSON.stringify({ time: accessTime }));
  if (this.checkCondition()) {
    this.refreshToken(true);
  }
  return {
    headers: new HttpHeaders({
      'Authorization': 'Bearer ' + token
    })
  };
}
else {
  this.router.navigate(['/login']);
}

}

0 个答案:

没有答案
相关问题