Can't set Content-type to Google Storage with the Google PHP Client

google-cloud-storage, php

Solution

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);

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

Problem

I'm using google-api-php-client 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); ``` 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?

Original source