我在尝试使用 swift 放置对象时遇到异常:
org.jclouds.http.HttpResponseException: Incomplete output stream connecting to PUT http://xxx.xx.xx.xxx:8080/v1/AUTH_2c5c2fbbfe22422496d5ebf6861199f2/myContainer1/ HTTP/1.1
at org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:162)
at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:93)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:76)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:47)
at here`org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:79)
at $Proxy66.put(Unknown Source)
at com.cis.app.Appxkl.JCloudsSwift.uploadObjectFromString(JCloudsSwift.java:194)
at com.cis.app.Appxkl.JCloudsSwift.main(JCloudsSwift.java:51)
Caused by: java.io.IOException: Incomplete output stream
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.invoke(JavaUrlHttpCommandExecutorService.java:112)
at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.invoke(JavaUrlHttpCommandExecutorService.java:72)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:141)
... 8 more
代码是:
InputStream is = new ByteArrayInputStream(data.getBytes("UTF-8"));
Payload payload = new InputStreamPayload(is);
payload.getContentMetadata().setContentLength((long) 1000);
ObjectApi objectApi = swiftApi.objectApiInRegionForContainer("RegionOne", CONTAINER_NAME);
String str = "strName";
objectApi.put(str, payload);
请任何人指导我如何解决这个问题