Unable to install Content-type in Google Storage using Google PHP Client

I am using google-api-php-client

Here's a bit where I upload the .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);

When checking, $gsoContentType is added, but the application/octet-streamdefault type is added in the cloud console .

Is there any other way to set the content type?

+4
source share
2 answers

Try it, 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' is its parameter. Take a look at line 39 at https://code.google.com/p/google-api-php-client/source/browse/tags/0.6.7/src/service/Google_ServiceResource.php

+4
source

. google-api-php-client.

. Google Cloud Storage , . $objects->update().

0

All Articles