Upload to the google cloud storage bucket doesn't work... Please someone help me

158 views
Skip to first unread message

Maddy Raen

unread,
Jan 2, 2014, 4:58:55 AM1/2/14
to google-api...@googlegroups.com

I am using the latest library google php-api-client

When i tried uploading i get the following error

PHP Warning:  file_get_contents(/upload/storage/v1beta2/b/filetransfer/o?uploadType=multipart): failed to open stream: No such file or directory in /src/Google/IO/Stream.php on line 109

User uploads the image to my server and i do processing on my server side and then post the image to my cloud storage bucket... this is my code guys

Once the user uploads the image, it will be processed and reside in /temp/ directory on my server and then i do the following
// Instantiate the Google Cloud Storage Client

                        $client = new Google_Client();
                        $client->setApplicationName("MY_CLOUD_STORAGE");
                        $service = new Google_Service_Storage($client);
                        if (isset($_SESSION['service_token'])) {
                            $client->setAccessToken($_SESSION['service_token']);
                        }
                        $key = file_get_contents($key_file_location);
                        $cred = new Google_Auth_AssertionCredentials(
                            $service_account_name,
                            array($gcs_url),
                            $key
                        );
                        $client->setAssertionCredentials($cred);
                        if($client->getAuth()->isAccessTokenExpired()) {
                          $client->getAuth()->refreshTokenWithAssertion($cred);
                        }
                        $_SESSION['service_token'] = $client->getAccessToken();
                        $objects = $service->objects;
                        $gso = new Google_Service_Storage_StorageObject();

                        $gso->setName("image.gif");
                       $imgdata = file_get_contents($server_image_path);
                        $postbody = array('data' => $imgdata);
try {
$result = $objects->insert('filetransfer', $gso, $postbody);
} catch(Exception $e) {
}
Reply all
Reply to author
Forward
0 new messages