0
ruby google API에 관한 질문이 있습니다.Ruby Google 스토리지 API 변경 공유 됨
Google 스토리지를 사용하여 이미지를 호스팅하려고했습니다. 모든 사용자가 이미지를 읽을 수있게하고 싶습니다. 지금까지 Google 클라우드 스토리지에 연결하고 이미지를 Storage에 업로드 할 수 있습니다. ACL을 변경,하지만 아무것도하지 않습니다 :
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
은 내가 ('publicRead'predefinedAcl)를 사용 : 그러나,이 API를 통해 권한을 변경할 수 없습니다, 코드 나는 다음과 같은 사용. "
https://console.developers.google.com/m/cloudstorage/b/# {bucket}/o/# {object}"과 같은 URL을 사용하여 이미지에 액세스하려면 스토리지 콘솔의 버튼을 수동으로 클릭해야 "공유 할 수 있습니다".
나는 API를 통해 모든 사람들에게 공개 된 링크를 얻을 수있는 방법이 있는지 알고 싶습니다. 감사합니다. .
그래,이 하나의 작업, 나는 내 일을 몇 일 후에도 작동하지만, 당신의 것이 더 좋아 보인다 고 생각합니다! –