In the snippet above, $options is a set of arguments that the stream will use when writing new objects, which can be set as the default options using stream_context_set_default.
所以在upload file中,插入一段改變File權限的程式,即可。
$default = stream_context_get_options( stream_context_get_default() );
$gcs_opts = [
'gs' => [
'acl' => 'public-read',
],
];
$context = array_replace_recursive( $default, $gcs_opts );
stream_context_set_default( $context );
這樣就可以將public的權限寫到物件中,可以用:
https://ccloudstorage.storage.googleapis.com/{object name} 或 http://storage.googleapis.com/{bocket name}/{object name}