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
$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) {
}