Bu konuda PHP ile subdomain.storage.googleapis.com/index.html alma kodunu paylaşacağım. Composer ile kütüphanenin yüklenmesi gerekiyor.
composer require google/cloud-storage
key.json yazan kısma Google Cloud Services Api den indirdiğimiz json keyinin, index.html yazan kısmına da index.html dosyamızın yolunu giriyoruz.
<?php
putenv("GOOGLE_APPLICATION_CREDENTIALS=key.json");
require 'vendor/autoload.php';
use GoogleCloudStorageStorageClient;
# Bucket oluşturma
$projectId = 'proje idniz';
# Instantiates a client
$storage = new StorageClient([
'projectId' => $projectId
]);
$bucketName = 'oluşturulacak bucket(site) adı';
$bucket = $storage->createBucket($bucketName);
# Dosya Yükleme
$storage = new StorageClient();
$bucket = $storage->bucket($bucketName);
$object = $bucket->upload(
fopen('index.html', 'r'),
[
'predefinedAcl' => 'publicRead'
]
);İşlem sonrası bucketismi.
storage.googleapis.com/index.html linki oluşmuş oluyor.
Blog linki
https://www.batukay.com/php-google-s...-api-kullanimi