Isaac
Isaac

Reputation: 2364

Rails - Upload private file to Google Cloud Storage

I am working on a Rails project and the uploaded files are being stored in Google's Cloud Storage (via Fog). Every file that is uploaded by default has the "Public Link" checkbox checked and the two permissions are for the owner as "Owner" and for "allUsers" as "Reader" (I viewed these settings through the Google Dev Console).

I would like to make it so that when a user uploads an attachment the default is actually for the "Public Link" checkbox to be unchecked and for there to be no permissions for "allUsers". Is this possible?

Upvotes: 2

Views: 586

Answers (2)

Isaac
Isaac

Reputation: 2364

For the :has_attached_file options, I added this:

:fog_public => false

Upvotes: 1

Mike Schwartz
Mike Schwartz

Reputation: 12145

Yes - you can accomplish this by changing the default object ACL on the bucket. You can do this with a gsutil command like:

gsutil defacl ch -d allUsers gs://your-bucket

This will remove the allUsers:R grant on the bucket's default object ACL, and objects uploaded after this point will not be publicly readable.

If you want to see the bucket's default object ACL before or after running this command, you can do:

gsutil defacl get gs://your-bucket

Upvotes: 1

Related Questions