CodexBloom - Programming Q&A Platform

OCI Data Transfer: implementing Large File Uploads to Object Storage from Java Application

👀 Views: 3 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-11
oci object-storage java file-upload sdk Java

I'm following best practices but I recently switched to I've looked through the documentation and I'm still confused about I am trying to upload large files (around 500 MB) to Oracle Cloud Infrastructure (OCI) Object Storage using a Java application, but I'm running into issues with timeouts and errors. I am utilizing the OCI Java SDK version 2.18.0 and have configured my client with the following code: ```java import com.oracle.bmc.objectstorage.ObjectStorageClient; import com.oracle.bmc.objectstorage.model.PutObjectRequest; import com.oracle.bmc.objectstorage.model.PutObjectResponse; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; public class ObjectStorageUploader { private final ObjectStorageClient client; private final String namespaceName; private final String bucketName; public ObjectStorageUploader(ObjectStorageClient client, String namespaceName, String bucketName) { this.client = client; this.namespaceName = namespaceName; this.bucketName = bucketName; } public void uploadFile(String objectName, File file) throws Exception { try (InputStream inputStream = new FileInputStream(file)) { PutObjectRequest putObjectRequest = PutObjectRequest.builder() .namespaceName(namespaceName) .bucketName(bucketName) .objectName(objectName) .contentLength(file.length()) .build(); PutObjectResponse response = client.putObject(putObjectRequest, inputStream); System.out.println("File uploaded with ETag: " + response.getETag()); } } } ``` The upload fails after about 2-3 minutes, and I receive the following behavior message: ``` java.util.concurrent.ExecutionException: com.oracle.bmc.model.BmcException: HTTP 504: Gateway Timeout ``` I have adjusted the `timeout` settings in the client configuration but have not had any success. I've also tried splitting the file into smaller chunks but that led to additional complexity in handling the file reassembly on the server side. I checked the OCI limits and confirmed that the Object Storage service is configured to allow uploads of large files. I am currently using a public subnet and have confirmed that the security lists allow the necessary traffic. Is there a better approach or configuration that I can try to successfully upload larger files to OCI Object Storage? Is this even possible? The stack includes Java and several other technologies. My team is using Java for this microservice. Thanks for taking the time to read this! Any ideas how to fix this?