以Express的响应角度渲染PDF(amazon aws s3)

时间:2019-03-17 08:26:05

标签: node.js angular express amazon-s3

我已经在 Amazon s3服务器上上传了一些PDF文件,我正在使用express作为后端来获取这些文件

#Calculate the mean and standard deviation for duration based on call classes

        mean_total_duration = rawdata[['cclass', 'Duration']].groupby('cclass').agg([np.mean, np.std])
        mean_total_duration.columns = mean_total_duration.columns.droplevel()

        # Define a function for a bar plot
        def barplot(x_data, y_data, error_data, x_label, y_label, title):
            _, ax = plt.subplots()
            # Draw bars, position them in the center of the tick mark on the x-axis
            ax.bar(x_data, y_data, color = '#539caf', align = 'center')
            # Draw error bars to show standard deviation, set ls to 'none'
            # to remove line between points
            ax.errorbar(x_data, y_data, yerr = error_data, color = '#297083', ls = 'none', lw = 2, capthick = 2)
            ax.set_ylabel(y_label)
            ax.set_xlabel(x_label)
            ax.set_title(title)

        # Call the function to create plot
        print(mean_total_duration.index.values)
        print(mean_total_duration['mean'])

        barplot(x_data = mean_total_duration.index.values
                , y_data = mean_total_duration['mean']
                , error_data = mean_total_duration['std']
                , x_label = 'call classes '
                , y_label = 'Call Duration'
                , title = 'Call Duration for call classes')

以快递方式正确提取了PDF,但是当我发送此数据作为对我的angular应用程序的响应,然后尝试通过浏览器呈现或显示它时,我无法显示

Component.ts文件

s3.getObject(bucketParams, function(err, data){
    if (!err){
        console.log("PDF recevied from amazon");
        result(data);}
    else
        console.log(err);
});

HTML文件

const url = 'http://localhost:5000/getPDF';
this.http.get(
    url,
    {  responseType: 'arraybuffer' as 'json'}
).subscribe(response => {
    this.link = response;
});

我没有收到任何错误,只是在Web浏览器控制台中“为所有索引建立索引”,但是没有显示pdf 请帮忙!

0 个答案:

没有答案