I am inserting images using Google Cloud Storage JSON API as shown in this sample, that needs to be shared publicly with read permissions. HTTP request looks like this:
我正在使用Google云端存储JSON API插入图片,如此示例所示,需要与读取权限一起公开共享。 HTTP请求如下所示:
var request = gapi.client.request({
'path': '/upload/storage/v1beta2/b/' + BUCKET + '/o',
'method': 'POST',
'params': {'uploadType': 'multipart'},
'headers': {'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'},
'body': multipartRequestBody});
My bucket already has 'Reader' permission for 'All Users', but inserted objects don't inherit that property. Following URL throw access denied till I click on 'Share Publicly' checkbox. http://commondatastorage.googleapis.com/bucketname%2Ffilename
我的存储桶已经拥有“所有用户”的“读者”权限,但插入的对象不会继承该属性。在点击“公开共享”复选框之后拒绝URL拒绝访问。 http://commondatastorage.googleapis.com/bucketname%2Ffilename
I need those image to be available as soon as inserted. Is there a way to share as part of HTTP insert request?
我需要插入后立即使用这些图像。有没有办法作为HTTP插入请求的一部分进行共享?
1 个解决方案
#1
7
There is a property that represents the default permissions of objects created in a bucket, but it's not the bucket permissions. Buckets have a separate property for this purpose called the "default object ACL." If you set this property to public-read, newly created objects will be publicly readable.
有一个属性表示在存储桶中创建的对象的默认权限,但它不是存储桶权限。为此,Buckets有一个单独的属性称为“默认对象ACL”。如果将此属性设置为public-read,则新创建的对象将是公共可读的。
If you have gsutil, you can easily set this property to public read like so:
如果您有gsutil,则可以轻松地将此属性设置为public read,如下所示:
gsutil defacl set public-read gs://mybucket
Alternately, you could modify your call to explicitly set the permissions. Part of your multipart upload is presumably a JSON description of the object being created. One of those properties is "acl", which you can set however you like.
或者,您可以修改调用以显式设置权限。您的分段上传的一部分可能是正在创建的对象的JSON描述。其中一个属性是“acl”,您可以根据需要设置它。
#1
7
There is a property that represents the default permissions of objects created in a bucket, but it's not the bucket permissions. Buckets have a separate property for this purpose called the "default object ACL." If you set this property to public-read, newly created objects will be publicly readable.
有一个属性表示在存储桶中创建的对象的默认权限,但它不是存储桶权限。为此,Buckets有一个单独的属性称为“默认对象ACL”。如果将此属性设置为public-read,则新创建的对象将是公共可读的。
If you have gsutil, you can easily set this property to public read like so:
如果您有gsutil,则可以轻松地将此属性设置为public read,如下所示:
gsutil defacl set public-read gs://mybucket
Alternately, you could modify your call to explicitly set the permissions. Part of your multipart upload is presumably a JSON description of the object being created. One of those properties is "acl", which you can set however you like.
或者,您可以修改调用以显式设置权限。您的分段上传的一部分可能是正在创建的对象的JSON描述。其中一个属性是“acl”,您可以根据需要设置它。