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

时间:2019-03-04 05:24:13

标签: oracle-cloud-infrastructure oci-java-sdk

我正在尝试使用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$1.apply(SimpleRetry.java:34)
    at com.oracle.bmc.objectstorage.transfer.internal.SimpleRetry$1.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$0(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)

4 个答案:

答案 0 :(得分:2)

请在Java客户端超时的同一台计算机上测试curl -v https://objectstorage.us-ashburn-1.oraclecloud.com,以确保没有连接问题。如果工作正常,则可以尝试在ClientConfiguration中更改超时值。您可以在此处查看更多详细信息:https://github.com/oracle/oci-java-sdk/issues/92

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

答案 1 :(得分:0)

在不了解有关配置文件(我不建议您将其发布在这里),您的本地区域和其他元素的更多信息的情况下,很难提供帮助。

建议您在https://support.oracle.com上打开支持记录,并确保选择“云”选项卡并将“服务”选择为“ Oracle Cloud Infrastructure”。

答案 2 :(得分:0)

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

答案 3 :(得分:0)

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