2
我試圖在谷歌雲平臺上設置存儲。老實說,現在我對做什麼感到困惑。使用php api在谷歌雲存儲中插入圖片
我正在使用以下代碼。
require_once("vendor/autoload.php");
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Storage\StorageObject;
use Google\Cloud\Storage;
$projectId = 'YOUR_PROJECT_ID';
$storage = new StorageClient([
'projectId' => 'xx',
'key'=> 'yy'
]);
$file_name = "imagename";
$obj = new StorageObject();
$obj->setName($file_name);
$storage->objects->insert(
"kmapsimage",
$obj,
['name' => $file_name, 'data' => file_get_contents("https://kmapst.blob.core.windows.net/images/kmap581b939a7a28c.jpeg"),'mimeType' => 'image/jpeg']
);
在執行函數時出現以下錯誤。
Argument 1 passed to Google\Cloud\Storage\StorageObject::__construct() must implement interface Google\Cloud\Storage\Connection\ConnectionInterface, none given, called in /var/www/html/test_imageupload.php on line 35 and defined in /var/www/html/vendor/google/cloud/src/Storage/StorageObject.php on line 71
我只是想上傳圖片到谷歌存儲。