无法打开文件以阅读[file link] laravel

问题描述

我正在尝试将带有文件URL附件的邮件发送给多个收件人,但是在邮递员中击中api时,抛出了无法打开文件以读取[文件链接]的错误,但是我正在复制文件链接并在浏览器中打开会完美打开。

我还检查了文件许可权,并参考了Stackoverflow上的一些答案,但没有帮助,请尽快帮助我。

enter image description here

import math

number = input('Your Number: ')
ways_ = input('sin/cos/tan: ')

try:
    problem = ways(number)
    answer = math.problem
    print(f'The value of {ways} of {number} is: {number}')
except:
    pass
    # anything else?? handle errors??

解决方法

尝试此操作,我最终对其进行了测试,并返回了文件

Storage::get('./public/TimeActivityReport/'.$file_name);

您还可以使用以下方法测试文件是否存在:

Storage::disk('local')->exists('public/TimeActivityReport/'.$file_name);

附加尝试:

$fileurl = Storage::path('public/TimeActivityReport/'.$file_name);

资源laravel docs