-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement predefined acl #4757
Implement predefined acl #4757
Conversation
a3c3774
to
54bb0fc
Compare
storage/google/cloud/storage/blob.py
Outdated
@@ -688,6 +691,9 @@ def _do_multipart_upload(self, client, stream, content_type, | |||
|
|||
if self.user_project is not None: | |||
name_value_pairs.append(('userProject', self.user_project)) | |||
if predefined_acl is not None: | |||
self._acl.save_predefined(predefined_acl) | |||
name_value_pairs.append(('predefinedAcl', predefined_acl)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
54bb0fc
to
295eb03
Compare
@tseaver PTAL, thanks. I set the acl after the blob was created as you had suggested. |
@chemelnucfin Moving the |
Sorry, I must have misunderstood you. I will take a look in a bit. Thanks. |
b970be1
to
1d0aae7
Compare
@tseaver PTAL at your convenience. Thanks. |
storage/tests/unit/test_blob.py
Outdated
@@ -1009,9 +1013,11 @@ def _initiate_resumable_helper( | |||
data = b'hello hallo halo hi-low' | |||
stream = io.BytesIO(data) | |||
content_type = u'text/plain' | |||
predefined_acl = 'private' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/tests/unit/test_blob.py
Outdated
@@ -1180,8 +1187,9 @@ def _do_resumable_helper(self, use_size=False, num_retries=None): | |||
client = mock.Mock(_http=transport, spec=['_http']) | |||
stream = io.BytesIO(data) | |||
content_type = u'text/html' | |||
predefined_acl = 'private' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/tests/unit/test_blob.py
Outdated
@@ -1225,20 +1233,21 @@ def _do_upload_helper(self, chunk_size=None, num_retries=None): | |||
stream = mock.sentinel.stream | |||
content_type = u'video/mp4' | |||
size = 12345654321 | |||
|
|||
predefined_acl = 'private' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/tests/unit/test_blob.py
Outdated
|
||
blob = self._make_one('blob-name', bucket=None) | ||
|
||
blob._acl = mock.create_autospec(ACL) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
fb2b43b
to
f411292
Compare
storage/tests/unit/test_blob.py
Outdated
@@ -1187,7 +1190,6 @@ def _do_resumable_helper(self, use_size=False, num_retries=None): | |||
client = mock.Mock(_http=transport, spec=['_http']) | |||
stream = io.BytesIO(data) | |||
content_type = u'text/html' | |||
predefined_acl = 'private' | |||
response = blob._do_resumable_upload( | |||
client, stream, content_type, size, num_retries, None) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
25578fb
to
00dfef0
Compare
@tseaver Hopefully this time is good. PTAL at your convenience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the other changes requested, please add explicit unit tests for ACL.valiate_predefined_acl
, including cases for None
, a valid XML acl, a valid JSON acl, and an invalid acl.
@@ -941,14 +965,18 @@ def upload_from_file(self, file_obj, rewind=False, size=None, | |||
warnings.warn(_NUM_RETRIES_MESSAGE, DeprecationWarning) | |||
|
|||
_maybe_rewind(file_obj, rewind=rewind) | |||
predefined_acl = ACL.validate_predefined(predefined_acl) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/google/cloud/storage/blob.py
Outdated
@@ -1109,7 +1145,7 @@ def create_resumable_upload_session( | |||
# to the `ResumableUpload` constructor. The chunk size only | |||
# matters when **sending** bytes to an upload. | |||
upload, _ = self._initiate_resumable_upload( | |||
client, dummy_stream, content_type, size, None, | |||
client, dummy_stream, content_type, size, None, None, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
00dfef0
to
8db085b
Compare
@tseaver added the unit test for validation. |
@tseaver I added the keyword arguments, PTAL and hopefully this is good! |
Closes #1660