You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Google cloud python API returns None for blob.owner attribute #136
I have created a Google bucket with "Fine-grained access control" and a few users have uploaded files to it. Using the python API I can't seem to get any information on who uploaded each. The blob.owner property just returns None:
I'm calling reload() there because the documentation states it's required to pull some attributes from the server. All other properties I try print fine (size, updated, etag, md5_hash, etc.).
How can I recover the uploader identification?
Environment details
OS type and version: Ubuntu 18.04
Python version: 3.7.0
pip version: 18.1
google-cloud-storage version: 1.20.0
Steps to reproduce
Place file in google bucket
Attempt to use API to get owner information from the blob
So if you have 10 people on a gcloud project and each of them can upload to the bucket, there's no way to find out who uploaded to the bucket unless each of them did these steps to set their own owner IDs?
If you make an authenticated request to upload an object and do not specify any object ACLs when you upload it, then you are listed as the owner of the object and the predefined projectPrivate ACL is applied to the object by default. This means:
You (the person who uploaded the object) are listed as the object owner. Object ownership cannot be changed by modifying ACLs. You can change object ownership only by overwriting an object.
You (the object owner) are granted OWNER permission on the object. If you attempt to give less than OWNER permission to the owner, Cloud Storage automatically escalates the permission to OWNER.
The project owners and project editors group have OWNER permission on the object.
The project team members group has READER permission on the object.
Took me a little while to figure out what was going wrong, thank you for your patience.
The issue is owner is only populated when projection=full but by default Blob.reload() uses projection=noAcl therefore owner is not populated. In order to fix this, the library should add a parameter for projection on Blob.reload(). @HemangChothani could you take a look at this?
A workaround for this is to use:
fromgoogle.cloudimportstorageimporttimeclient=storage.Client()
bucket=client.get_bucket("bucket-name")
print(bucket.iam_configuration.uniform_bucket_level_access_enabled)
blob=bucket.blob("assets/test.mp4")
blob.patch() # nothing is updated but uses `projection=full`print(blob.owner)
Activity
jorvis commentedon May 6, 2020
As a note, I put this on StackOverflow first and another user verified the same problem.
https://stackoverflow.com/questions/61466801/google-cloud-python-api-returns-none-for-blob-owner-attribute?noredirect=1#comment109019518_61466801
HemangChothani commentedon May 7, 2020
@jorvis As i found in the documentation here, first you need to set the owner locally and then you can retrieve it.
Sample:
Else other info about blob you can found through acl.
jorvis commentedon May 7, 2020
So if you have 10 people on a gcloud project and each of them can upload to the bucket, there's no way to find out who uploaded to the bucket unless each of them did these steps to set their own owner IDs?
HemangChothani commentedon May 8, 2020
Pulling in @frankyn who know more and better about this. Could you please comment on this?
frankyn commentedon May 13, 2020
Hi @jorvis,
Per documentation: https://cloud.google.com/storage/docs/access-control/lists#defaultobjects
Took me a little while to figure out what was going wrong, thank you for your patience.
The issue is
owneris only populated whenprojection=fullbut by defaultBlob.reload()usesprojection=noAclthereforeowneris not populated. In order to fix this, the library should add a parameter for projection onBlob.reload(). @HemangChothani could you take a look at this?A workaround for this is to use:
jorvis commentedon May 15, 2020
Thanks all!