代码之家  ›  专栏  ›  技术社区  ›  BlackPearl

访问存储在Amazon S3中的图像时出错

  •  1
  • BlackPearl  · 技术社区  · 6 年前

    我使用Laravel成功地将一张图片上传到AmazonS3。当我在线检查bucket时,图像就在那里,但是当我点击查看它时,它会给出以下错误:

    The webpage at http://.. might be temporarily down or it may have moved permanently to a new web address.
    ERR_CONTENT_DECODING_FAILED
    

    以下是我的上传代码:

    $imagedata = base64_decode(request('passport'));
                $imageFile = Image::make($imagedata)->resize(150, 150)->stream();
                $imageFile = $imageFile->__toString();
                $filename = str_random(4).str_random(4).str_random(6).'.jpg';
                $s3 = \Storage::disk('s3');
                $s3->put('images/passport/'.$filename, $imageFile, 'public');
                $passport = $s3->url('images/passport/'.$filename);
    

    我也无法在我的页面上查看此图像。

    更新

    在使用dompdf转换为pdf的视图上,使用存储的URL显示图像。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Monte Cristo    6 年前

    让我们先尝试手动上载另一个图像。如果您可以查看该图像,可能您的上载过程更改了图像格式。

    如果不是,可能问题来自AWS。进一步检查权限、区域…