doukuangxun5382 2019-07-06 23:39
浏览 47

fopen使用AWS S3包装器以模式x失败

TL;DR: I'm using the Nette Tracy library that creates a summary (.log) and a detailed (.html) file on any errors that occur, and I'm attempting to upload them to AWS S3. The .log file appears successfully but the .html file is nowhere to be seen.


I'm using the Nette Tracy library and trying to upload all output to an S3 bucket.

So far I've created the S3 wrapper and manually triggered an exception to test it out but it only succeeds in part. The S3 wrapper exists and works in part as an initial "overview" document (error.log) is successfully created - it's just the HTML document that's not appearing. It works fine with local storage, but S3 would be preferred.

When it tries to log the actual exception details itself (a HTML file) the fopen function returns false. As a result, false is returned from the function too (function below) and the file isn't created.

In the error.log file that is actually uploaded, the below is recorded (bucket name and path removed):

PHP Warning: fopen(s3:\BUCKET\debug\tracy\exception--2019-07-07--00-30--459a553c82.html): failed to open stream: No such file or directory in C:\path\to\file\tracy\Tracy\BlueScreen\BlueScreen.php:97 @ http://mydevelopment.site

Not really sure where to go from here? Any help pointers appreciated!

This is the code which is part of the Tracy library that records the full exception/error details:

    /**
     * Renders blue screen to file (if file exists, it will not be overwritten).
     */
    public function renderToFile(\Throwable $exception, string $file): bool
    {
        if ($handle = @fopen($file, 'x')) {
            ob_start(); // double buffer prevents sending HTTP headers in some PHP
            ob_start(function ($buffer) use ($handle): void { fwrite($handle, $buffer); }, 4096);
            $this->renderTemplate($exception, __DIR__ . '/assets/page.phtml', false);
            ob_end_flush();
            ob_end_clean();
            fclose($handle);
            return true;
        }
        return false;
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看