无法使用Google PHP客户端将Content-type设置为Google Storage [英] Can't set Content-type to Google Storage with the Google PHP Client

查看:88
本文介绍了无法使用Google PHP客户端将Content-type设置为Google Storage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 google-api-php-client

这是我上传.jpg图片的地方.

Here's the bit where I upload a .jpg image.

$postbody = array("data" => $imgData);
$gso = new Google_StorageObject();

$gso->setName($imageName);
$contentType = 'image/jpg';
$gso->setContentType($contentType);
$resp = $objects->insert('bucket-name', $gso, $postbody);

通过检查$gso已添加ContentType,但在云控制台中添加了默认的application/octet-stream类型.

By inspecting $gso ContentType is being added but in the cloud console is added with the default application/octet-stream type.

还有另一种设置内容类型的方法吗?

Is there another way to set the content type?

推荐答案

尝试一下,它对我有用:

Try this, it worked for me:

$postbody = array('mimeType' => 'image/jpeg', "data" => $imgData);
$gso = new Google_StorageObject();

$gso->setName($imageName);
$resp = $objects->insert('bucket-name', $gso, $postbody);

似乎'mimeType'是它的一个参数. 看看 https://code.google.com/p/google-api-php-client/source/browse/tags/0.6.7/src/service/Google_ServiceResource.php

It seems 'mimeType' its a parameter. Take a look at line 39 in https://code.google.com/p/google-api-php-client/source/browse/tags/0.6.7/src/service/Google_ServiceResource.php

这篇关于无法使用Google PHP客户端将Content-type设置为Google Storage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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