在 Laravel 中下载 Cloudinary 文件

问题描述 投票:0回答:1

请问我有两个问题要问;

第一个是如何在laravel中下载cloudinary文件? 我已经尝试了chatGPT提供的所有方法。它下载了文件(pdf),但文件大小为0位,我无法打开它。

这个

public function downloadPdf($token){
  $user = User::where('info_token', $token)->first();
  $filePath=$user->cv_URL;
  $filename='my_cv.pdf';
     // Fetch the PDF file content from the Cloudinary URL
    $response = Http::get($filePath);

    // Check if the response is successful
    if (!$response->successful()) {
        abort(500, 'Failed to fetch PDF file from Cloudinary');
    }

    // Set the appropriate headers for the file download
    return response($response->body())
        ->header('Content-Type', 'application/pdf')
        ->header('Content-Disposition', 'attachment; filename="' . $filename . '"');
  }
``` is how I am trying to get it.


The second issue is that.
I'm trying to send an email, but the email doesn't use the email I provided as (from email) but uses the name I provided as (from name) and the email I used to which is in .env file.
Please how can I resolve it?

This is the code;

公共函数sendMail(请求$request,$token){ $user = User::where('info_token', $token)->first(); $邮件数据=[ '标题'=>$请求->主题, 'body'=>$请求->正文 ];

$mail = new ContactMail($mailData); $mail->from($request->email, $request->lastName);

//发送邮件 邮件::发送($user->email)->send($mail); return response()->json(['message' => '邮件发送成功。', 'error' => false]); }



It uses the name I provided here "$mail->from($request->email, $request->lastName)" but not the email

I wan you to please help me out.
laravel email cloudinary
1个回答
0
投票

需要注意的一件事是,拥有免费帐户的 Cloudinary 客户默认无法交付 PDF 格式的文件。这是一项安全措施。如果您想传送 PDF 文件,您需要向支持人员开具票证才能启用该功能。

更多信息在这里:https://cloudinary.com/blog/uploading_managing_and_delivering_pdfs

© www.soinside.com 2019 - 2024. All rights reserved.