如何将文件上传到 OCI 对象存储

How to upload a file to OCI Object storage

我正在尝试使用 UploadObjectExample.java 代码将文件上传到 OCI 对象存储。我在连接到对象存储 URL 时 运行 遇到连接超时错误。 OCI CLI 使用相同的配置文件将文件成功上传到 OCI 配置。

这是错误日志:

Exception in thread "main" com.oracle.bmc.model.BmcException: (-1, null, true) Timed out while communicating to: https://objectstorage.us-ashburn-1.oraclecloud.com (outbound opc-request-id: 1EB5AA4A7FD64D58A54F876AD0C9E83B)
    at com.oracle.bmc.http.internal.RestClient.convertToBmcException(RestClient.java:572)
    at com.oracle.bmc.http.internal.RestClient.put(RestClient.java:380)
    at com.oracle.bmc.objectstorage.ObjectStorageClient.putObject(ObjectStorageClient.java:1053)
    at com.oracle.bmc.objectstorage.transfer.internal.SimpleRetry.apply(SimpleRetry.java:34)
    at com.oracle.bmc.objectstorage.transfer.internal.SimpleRetry.apply(SimpleRetry.java:26)
    at com.oracle.bmc.objectstorage.transfer.UploadManager.singleUpload(UploadManager.java:111)
    at com.oracle.bmc.objectstorage.transfer.UploadManager.upload(UploadManager.java:73)
    at UploadObjectExample.main(UploadObjectExample.java:74)
Caused by: javax.ws.rs.ProcessingException: java.net.SocketTimeoutException: connect timed out
    at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:284)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
    at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke[=10=](JerseyInvocation.java:753)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:752)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:445)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.put(JerseyInvocation.java:334)
    at com.oracle.bmc.http.internal.ForwardingInvocationBuilder.put(ForwardingInvocationBuilder.java:141)
    at com.oracle.bmc.http.internal.RestClient.put(RestClient.java:377)

在不了解更多配置文件的情况下(我不建议你 post 这里),你的家乡和其他元素很难提供帮助。

我建议您在 https://support.oracle.com 打开支持票,确保您 select 云选项卡和服务为 "Oracle Cloud Infrastructure"。

请测试 curl -v https://objectstorage.us-ashburn-1.oraclecloud.com from the same machine where the Java client times out, just to make sure there are no connection issues. If it works fine you may try to change the timeout value in ClientConfiguration. You can see more details here: https://github.com/oracle/oci-java-sdk/issues/92

在创建支持票之前,您还可以尝试在 github/oci-java-sdk 上创建一个新问题。

您在使用代理吗?如果是这样,您可能需要使用 OCI Java SDK ApacheConnector.

这是代理的问题。这已通过使用 ash7 代理解决。