Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GSUTIL cp file from server to bucket and make file public

Using this command in my server from a php file:

exec(gsutil cp /path/to/file/on/server/namefile.ext gs://nameBucket/dir/namefile.ext > /dev/null 2>&1) 

i got the namefile.ext on bucket, in the correct directory...but need to make this file public readable.

Already tried to put this command (at the end of file, for make that public) but nothing to do:

exec(gsutil iam ch allUsers:objectViewer gs://nameBucket/dir/namefile.ext > /dev/null 2>&1)

So, upload works but I need to make file readable without my interaction from "browser" of bucket. There is a way to do this? Maybe into cp command?

like image 375
tidpe Avatar asked Apr 11 '18 10:04

tidpe


1 Answers

The gsutil iam ch allUsers:objectViewer command you used is meant to make all objects in a bucket publicly readable, but you provided it with the url of the object.

So, if you want to make the specific file publicly readable:

gsutil acl ch -u AllUsers:R gs://nameBucket/dir/namefile.ext

If you want to make all objects in a bucket publicly readable:

gsutil iam ch allUsers:objectViewer gs://nameBucket/

This is documented here.

like image 70
LundinCast Avatar answered Oct 17 '22 13:10

LundinCast