0
我有一个关于红宝石谷歌API的问题。红宝石谷歌存储API更改公共共享
我试图使用Google存储来托管图片。我想让每个用户都能够读取图像。到目前为止,我可以连接到谷歌云存储并将图像上传到存储。然而,我无法通过API修改权限,代码我用如下:
def build_client
client = Google::APIClient.new()
key = Google::APIClient::PKCS12.load_key('client.p12', 'notasecret')
service_account = Google::APIClient::JWTAsserter.new(
'[email protected]account.com',
'https://www.googleapis.com/auth/devstorage.full_control',
key)
client.authorization = service_account.authorize
client
end
def send_image_file(file_path, upload_file_name, client)
storage = client.discovered_api('storage', 'v1beta2')
media = Google::APIClient::UploadIO.new(file_path, 'image/*')
result = client.execute(
api_method: storage.objects.insert,
media: media,
parameters: {
uploadType: 'media',
predefinedAcl: 'publicRead',
bucket: 'portlight_images',
name: upload_file_name,
projection: 'full'
}
)
result
end
我使用(predefinedAcl:“publicRead”)更改ACL,但它不会做任何事情。当我想使用像“https://console.developers.google.com/m/cloudstorage/b/# {bucket}/o /#{object}”这样的URL访问映像时,我必须手动点击存储控制台上的按钮才能使其“共享共享”。
我想知道是否有任何方法可以通过API将链接公开给大家。 谢谢。
是的,这一个工作,我发现我的工作也在几天后,但你的似乎更好,谢谢! – 2015-03-25 19:21:12