簡體   English   中英

AWS PDF 文件顯示在 Laravel 的引導程序模型中

[英]AWS PDF file show in bootstrep model in Laravel

我已經下載了aws url

https://xxx-xx-dev.s3.ap-south-1.amazonaws.com/std_check/6557122022151745398XtquBSY.pdf

當此 url 放入 ifrem 時,文件會自動下載,而不是引導模型中的視圖。 我的代碼在這里,

查看文件是

function PDFOPEN(path) {
    $.ajax({
        type: 'post',
        url: '{{ route('background.pdf.show') }}',
        data: {
            "_token": "{{ csrf_token() }}",
            'path':path
        },
        success: function(data) {
            if (data.status == true) {
            
            } else {
                toastr.error(data.message);
            }
           
        }
    });
}

控制器文件是

    public function BackgroundVerifyShow(Request $request)
    {
        $file = \Storage::disk('s3')->url($request->path);
        header('Content-Type: application/pdf');
        header(sprintf("Content-disposition: inline;filename=%s", basename($file)));
        @readfile($file);
    }

那么,在 bootsrep 模型之后如何在 ajax succss 中讀取這個文件

readfile函數將返回truefalse

public function BackgroundVerifyShow(Request $request)
    {
        $file = \Storage::disk('s3')->url($request->path);

        header('Content-Type: application/pdf');
        header(sprintf("Content-disposition: inline;filename=%s", basename($file)));
        header("Content-Type: " . $asset->mime);

        echo json_encode({status => readfile($file)});
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM