def test_object_acl(self): object_name = "test1" content = "test1" self.client.put_object(self.bucket_name, object_name, content) for bucket in self.client.list_objects(self.bucket_name): print(bucket) print(self.client.get_object_acl(self.bucket_name, object_name)) objectAcl = AccessControlList() objectAcl.add_grant(Grant(Grantee("111"), Permission.READ)) objectAcl.add_grant(Grant(Grantee("109901"), Permission.FULL_CONTROL)) objectAcl.add_grant(Grant(Grantee(acl_ak), Permission.FULL_CONTROL)) self.client.set_object_acl(self.bucket_name, object_name, objectAcl) acl = self.client.get_object_acl(self.bucket_name, object_name) self.assertTrue(objectAcl.is_subset(acl)) acl_client = GalaxyFDSClient( acl_ak, acl_access_secret, FDSClientConfiguration(region_name, False, False, False, endpoint=endpoint)) self.assertTrue( self.client.does_object_exists(self.bucket_name, object_name)) print(acl_client.get_object(self.bucket_name, object_name)) self.client.delete_object(self.bucket_name, object_name) self.assertFalse( self.client.does_object_exists(self.bucket_name, object_name))
def test_object_acl(self): object_name = "test1" content = "test1" self.client.put_object(self.bucket_name, object_name, content) for bucket in self.client.list_objects(self.bucket_name): print(bucket) print(self.client.get_object_acl(self.bucket_name, object_name)) objectAcl = AccessControlList() objectAcl.add_grant(Grant(Grantee("111"), Permission.READ)) objectAcl.add_grant(Grant(Grantee("109901"), Permission.FULL_CONTROL)) objectAcl.add_grant(Grant(Grantee(acl_ak), Permission.FULL_CONTROL)) self.client.set_object_acl(self.bucket_name, object_name, objectAcl) acl = self.client.get_object_acl(self.bucket_name, object_name) self.assertTrue(objectAcl.is_subset(acl)) acl_client = GalaxyFDSClient(acl_ak, acl_access_secret, FDSClientConfiguration(region_name, False, False, False, endpoint=endpoint)) self.assertTrue( self.client.does_object_exists(self.bucket_name, object_name)) print(acl_client.get_object(self.bucket_name, object_name)) self.client.delete_object(self.bucket_name, object_name) self.assertFalse( self.client.does_object_exists(self.bucket_name, object_name))
print(bucket) print("---end---") # Check and create the bucket if not fds_client.does_bucket_exist(bucket_name): fds_client.create_bucket(bucket_name) ##################### ##################### # Put a string object object_name = 'test1.txt' object_content = 'Hello world! This is a simple test!' fds_client.put_object(bucket_name, object_name, object_content) # Get the object content obj = fds_client.get_object(bucket_name, object_name) for chunk in obj.stream: sys.stdout.write(chunk) print('\n') # Download the object file data_file = "/tmp/fds_file" fds_client.download(bucket_name, object_name, data_file) data_file2 = "/tmp/fds_file2" fds_client.download_object_with_uri("fds://" + bucket_name + "/" + object_name, data_file2) # Delete the object fds_client.delete_object(bucket_name, object_name) #####################
print bucket print # Check and create the bucket if not fds_client.does_bucket_exist(bucket_name): fds_client.create_bucket(bucket_name) ##################### ##################### # Put a string object object_name = 'test1.txt' object_content = 'Hello world! This is a simple test!' fds_client.put_object(bucket_name, object_name, object_content) # Get the object content obj = fds_client.get_object(bucket_name, object_name) for chunk in obj.stream: sys.stdout.write(chunk) print '\n' # Download the object file data_file = "/tmp/fds_file" client.download(bucket_name, object_name, data_file) data_file2 = "/tmp/fds_file2" client.download_object_with_uri("fds://" + bucket_name + "/" + object_name, data_file2) # Delete the object fds_client.delete_object(bucket_name, object_name) ##################### #####################