Javascript AngularJS下载图像并显示为HTML

Javascript AngularJS下载图像并显示为HTML,javascript,angularjs,image,web-services,download,Javascript,Angularjs,Image,Web Services,Download,我正在尝试实现“图像配置文件”功能。 我过去常常将图像上传到webservice服务器(java),现在我想让图像显示在用户配置文件页面上 在webservice服务器中,我编写了以下方法: @GET @Path("/downloadFile") @Produces("application/octet-stream") public Response downloadFile(@FormParam("documentId") long documentId) { AssessmentD

我正在尝试实现“图像配置文件”功能。 我过去常常将图像上传到webservice服务器(java),现在我想让图像显示在用户配置文件页面上

在webservice服务器中,我编写了以下方法:

@GET
@Path("/downloadFile")
@Produces("application/octet-stream")
public Response downloadFile(@FormParam("documentId") long documentId) {
    AssessmentDocument doc = this.documentRepository.findOne(documentId);
    File file = new File(doc.getDocumentPath() + doc.getDocumentName());
    ResponseBuilder response = Response.ok((Object) file);
    response.header("Content-Disposition", "attachment; filename=\"" + doc.getDocumentName() + "\"");
    return response.build();
}
在Angular服务中,我编写了调用服务下载的函数:

    /**
     *  download file
     * @param user
     * @returns {*}
     */
    this.downloadFilePromise = function (fileId) {
        var deferred = $q.defer();
        $http({
            method: 'GET',
            headers: {'Content-Type': 'application/octet-stream'},
            url: '.../downloadFile?documentId=' + fileId
        }).success(function (data, status) {
            deferred.resolve(data);
        }).error(function (data, status) {
            deferred.reject(data);
        });
        return deferred.promise;
    }
数据已成功返回,但我不知道如何处理从服务器返回的数据以显示为HTML

谢谢你的帮助

非常感谢,