简体   繁体   English

如何直接从亚马逊 s3 下载文件?

[英]How to download files directly from amazon s3?

This is my file uploading function:这是我上传 function 的文件:

$file = $req->file('upload_file');
$name = $file->getClientOriginalName();
$fileName = time() . rand(1, 10000) . '_' . $name;
if($file) {
  $storage = \Storage::disk('s3')->put($fileName, file_get_contents($file), 'public');
}
if ($storage) {
  $savePdf = Pdf_exports::create(
    [
      'pdf_name' => $fileName,
    ]
  );
}

I'm using jQuery DataTables to list the files.我正在使用 jQuery DataTables 列出文件。 I'm creating the download links like so:我正在创建下载链接,如下所示:

 $('td:eq(6)', nRow).html('<div class="actionGrp"><a href="' + URL_general + '/dowlnoadPdf?id=' + aData.id + '" data-tooltip="tooltip" data-placement="top" title="Download"><span class="fa fa-download"></span></a></div>').addClass('txt-center');

How can I download the PDF directly when clicking the the download button?点击下载按钮时如何直接下载PDF?

Finally i got the Answer最后我得到了答案

return Storage::disk('s3')->download($pdf_name);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM