CodexBloom - Programming Q&A Platform

OCI Object Storage: 'Access Denied' scenarios When Attempting to Move Objects Between Buckets Using Python

👀 Views: 20 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
oci object-storage python-sdk Python

I'm trying to implement I'm working on a project and hit a roadblock. I'm working on a personal project and I'm currently working with Oracle Cloud Infrastructure (OCI) Object Storage and running into a frustrating scenario when trying to move objects between buckets using the Python SDK (version 3.0.0). I'm leveraging the `oci` library to perform this operation, but keep receiving the behavior message `Access Denied` when I attempt to use the `move_object` method. Here's a snippet of the code I'm using: ```python import oci config = oci.config.from_file() # Assuming config file is set up correctly object_storage_client = oci.object_storage.ObjectStorageClient(config) source_bucket_name = 'source-bucket' target_bucket_name = 'target-bucket' object_name = 'my-object.txt' try: # Copy the object first copy_response = object_storage_client.copy_object( target_bucket_name, object_name, oci.object_storage.models.CopyObjectDetails( source_bucket_name=source_bucket_name, source_object_name=object_name ) ) print(f'Object copied: {copy_response.data}') # Attempting to delete the source object afterwards delete_response = object_storage_client.delete_object(source_bucket_name, object_name) print(f'Object deleted: {delete_response.status}') except oci.exceptions.ServiceError as e: print(f'behavior: {e}') ``` I've ensured that both buckets exist and that the object `my-object.txt` is present in the source bucket. The IAM policies seem fine, as I'm using a user with `object_storage.objects.read`, `object_storage.objects.write`, and `object_storage.objects.delete` permissions for both buckets. However, I'm not able to move the object due to the access denial. I suspect that it might be an scenario with the cross-bucket permissions or perhaps the way I'm trying to move the object isn't supported. Could someone guide to understand what might be going wrong or if there are additional permissions I need to set up? Any guidance would be greatly appreciated! What am I doing wrong? This issue appeared after updating to Python 3.11. This is happening in both development and production on Ubuntu 22.04. Hoping someone can shed some light on this. I'm developing on Ubuntu 20.04 with Python. Any help would be greatly appreciated!