我正在使用最新的库google
php-api-client
当我尝试上传时,我收到以下错误
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
用户将图像上传到我的服务器,我在服务器端进行处理,然后将图像发布到我的云存储桶......这是我的代码人员
一旦用户上传了图像,它就会被处理并驻留在我服务器上的/temp/
目录中,然后我会执行以下操作
// 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('uploadType' => 'multipart', 'data' => $imgdata);
try {
$result = $objects->insert('filetransfer', $gso, $postbody);
} catch(Exception $e) {
}