Amazon S3的 - 下载图像,而不是显示在浏览器 [英] amazon s3 - image downloading instead of displaying in browser

查看:443
本文介绍了Amazon S3的 - 下载图像,而不是显示在浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是推动我疯了。我使用的PHP SDK上传图片到S3。每当我浏览到该图片的URL,浏览器下载而不是显示它的形象。

我认为它是与内容类型。

  // prepare上传文件到S3桶。
        $ S3-> create_object($桶,$ FILE_NAME,阵列(
                '的contentType => 二进制/八位字节流,
                ACL=> AmazonS3 :: ACL_PUBLIC
        ));
 

你能帮忙吗?

感谢

解决方案

  $ S3-> create_object($桶,$ FILE_NAME,阵列(
                    '文件上传'=> $ resized_image,
                    '的contentType => $ _FILES ['形象'] ['类型'],
                    ACL=> AmazonS3 :: ACL_PUBLIC
            ));
 

This is driving me mad. I am uploading images to S3 using the php SDK. Whenever I browse to the image URL, the browser downloads the image opposed to displaying it.

I think its something to do with content type.

        // Prepare to upload the file to S3 bucket.
        $s3->create_object($bucket, $file_name, array(
                'contentType' => 'binary/octet-stream',
                'acl' => AmazonS3::ACL_PUBLIC
        ));

Can you help?

thanks

解决方案

            $s3->create_object($bucket, $file_name, array(
                    'fileUpload' => $resized_image,
                    'contentType' => $_FILES['image']['type'],
                    'acl' => AmazonS3::ACL_PUBLIC
            ));

这篇关于Amazon S3的 - 下载图像,而不是显示在浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆