CodexBloom - Programming Q&A Platform

OCI Object Storage: How to Handle 'Precondition scenarios' scenarios When Uploading Large Files

👀 Views: 31 💬 Answers: 1 📅 Created: 2025-06-13
oci object-storage python-sdk Python

I've been banging my head against this for hours. I'm building a feature where I'm learning this framework and I just started working with I'm maintaining legacy code that Quick question that's been bugging me - I'm currently working on an application that uploads large files to OCI Object Storage using the Python SDK (version 2.20.0)... During the upload of files larger than 5GB, I'm working with a 'Precondition Failed' behavior, which is quite frustrating. I've tried breaking the files into smaller parts and using multipart uploads, but I still run into the same scenario. Here's a snippet of my upload code: ```python import oci # Initialize the client config = oci.config.from_file() object_storage_client = oci.object_storage.ObjectStorageClient(config) namespace = object_storage_client.get_namespace().data bucket_name = 'my_bucket' file_path = 'path/to/large_file.dat' # Upload configuration with open(file_path, 'rb') as file: # Multipart upload multipart_upload = object_storage_client.create_multipart_upload(namespace, bucket_name, 'large_file.dat') upload_id = multipart_upload.data.id # Read and upload parts part_size = 10 * 1024 * 1024 # 10 MB parts = [] while True: data = file.read(part_size) if not data: break part = object_storage_client.upload_part(namespace, bucket_name, 'large_file.dat', upload_id, len(parts) + 1, data) parts.append(part) # Commit the upload object_storage_client.commit_multipart_upload(namespace, bucket_name, 'large_file.dat', upload_id, parts) ``` The behavior I'm getting states: `OCI behavior: Code: 412, Message: Precondition Failed`. I've double-checked the bucket policies and confirmed that I have the appropriate permissions to upload files. Additionally, I’ve ensured that the file isn't being modified during the upload process. Has anyone else faced this scenario or know what might be going wrong? Any insights or suggestions would be greatly appreciated! Is there a better approach? Any ideas what could be causing this? Any ideas what could be causing this? I'm on Windows 10 using the latest version of Python. Thanks in advance! I've been using Python for about a year now. What would be the recommended way to handle this? Thanks for any help you can provide!