CodexBloom - Programming Q&A Platform

OCI Object Storage Upload scenarios with 'InvalidObjectName' scenarios When Using Multipart Upload in Java SDK

👀 Views: 35 đŸ’Ŧ Answers: 1 📅 Created: 2025-07-31
oci object-storage java-sdk Java

I'm not sure how to approach This might be a silly question, but I'm trying to upload a large file to OCI Object Storage using the Java SDK's multipart upload feature... However, I keep working with an 'InvalidObjectName' behavior when the upload is initiated. The object name I am using is derived from a user's input, and I take care to sanitize it, but I suspect there might be some character issues since the behavior is thrown right at the beginning of the upload process. Here's the relevant code snippet: ```java import com.oracle.bmc.objectstorage.ObjectStorageClient; import com.oracle.bmc.objectstorage.model.CreateMultipartUploadRequest; import com.oracle.bmc.objectstorage.model.CreateMultipartUploadDetails; String namespace = "myNamespace"; String bucketName = "myBucket"; String objectName = "user-input-file.txt"; // User input ObjectStorageClient client = new ObjectStorageClient(config); CreateMultipartUploadDetails details = CreateMultipartUploadDetails.builder() .objectName(objectName) .contentType("text/plain") .build(); CreateMultipartUploadRequest request = CreateMultipartUploadRequest.builder() .namespaceName(namespace) .bucketName(bucketName) .createMultipartUploadDetails(details) .build(); try { client.createMultipartUpload(request); } catch (BmcException e) { System.err.println("behavior: " + e.getMessage()); // 'InvalidObjectName' } ``` I've tried different object names, ensuring they comply with the naming rules from the OCI documentation, which state that object names must be URL-safe and want to contain control characters or certain special characters. I've also checked the length of the object name to ensure it's within the acceptable range. Additionally, I used a hardcoded object name that is simple and valid, like "test.txt," and that worked fine, so it seems like the question is with how I'm handling the user input. Any guidance on what specific characters or formatting might be causing this scenario would be greatly appreciated. For context: I'm using Java on Windows. What am I doing wrong? For context: I'm using Java on Ubuntu. This is my first time working with Java stable.