Google cloud storage 如何使用访问权限和密钥访问Google云存储
我有访问Google云存储的权限和密钥,我想使用这些凭据实例化一个客户端。我一直在看教程,遇到了以下示例:Google cloud storage 如何使用访问权限和密钥访问Google云存储,google-cloud-storage,Google Cloud Storage,我有访问Google云存储的权限和密钥,我想使用这些凭据实例化一个客户端。我一直在看教程,遇到了以下示例: public class QuickstartSample { public static void main(String... args) throws Exception { // Instantiates a client Storage storage = StorageOptions.getDefaultInstance().getService(); /* Perform s
public class QuickstartSample {
public static void main(String... args) throws Exception {
// Instantiates a client
Storage storage = StorageOptions.getDefaultInstance().getService();
/* Perform some bucket action */
}
}
在实例化客户机时,是否有任何方法可以以类似于AWS和Minio的方式传递访问
和机密
密钥,如下所示:
minioClient = new MinioClient("server URL", "accessKey",
"secretKey");
我非常感谢您的帮助。如您在“使用Google云客户端库时,不需要在代码中明确指定凭据”
虽然还有一些其他选项可以在代码中对客户端进行身份验证,但它们都没有像在AWS bucket中那样使用访问和密钥。您有许多选项可以在代码中实现该身份验证,例如在代码中使用JSON服务帐户密钥或使用OAuth2访问令牌。我按照您提供的链接,从IAM&ADMIN页面下载了一个
key.JSON
文件,之后就非常简单了。再次感谢你澄清这一点。