1+ /*
2+ * Licensed to the Apache Software Foundation (ASF) under one
3+ * or more contributor license agreements. See the NOTICE file
4+ * distributed with this work for additional information
5+ * regarding copyright ownership. The ASF licenses this file
6+ * to you under the Apache License, Version 2.0 (the
7+ * "License"); you may not use this file except in compliance
8+ * with the License. You may obtain a copy of the License at
9+ *
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ *
12+ * Unless required by applicable law or agreed to in writing,
13+ * software distributed under the License is distributed on an
14+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+ * KIND, either express or implied. See the License for the
16+ * specific language governing permissions and limitations
17+ * under the License.
18+ */
19+
120package samples ;
221
322import java .io .ByteArrayInputStream ;
423import java .io .IOException ;
524
625import com .aliyun .oss .ClientException ;
7- import com .aliyun .oss .OSSClient ;
26+ import com .aliyun .oss .OSS ;
27+ import com .aliyun .oss .OSSClientBuilder ;
828import com .aliyun .oss .OSSException ;
929import com .aliyun .oss .model .Callback ;
1030import com .aliyun .oss .model .Callback .CalbackBodyType ;
@@ -29,7 +49,7 @@ public class CallbackSample {
2949
3050 public static void main (String [] args ) throws IOException {
3151
32- OSSClient ossClient = new OSSClient (endpoint , accessKeyId , accessKeySecret );
52+ OSS ossClient = new OSSClientBuilder (). build (endpoint , accessKeyId , accessKeySecret );
3353
3454 try {
3555 String content = "Hello OSS" ;
@@ -49,8 +69,8 @@ public static void main(String[] args) throws IOException {
4969
5070 PutObjectResult putObjectResult = ossClient .putObject (putObjectRequest );
5171 byte [] buffer = new byte [1024 ];
52- putObjectResult .getCallbackResponseBody ().read (buffer );
53- putObjectResult .getCallbackResponseBody ().close ();
72+ putObjectResult .getResponse (). getContent ().read (buffer );
73+ putObjectResult .getResponse (). getContent ().close ();
5474
5575 } catch (OSSException oe ) {
5676 System .out .println ("Caught an OSSException, which means your request made it to OSS, "
0 commit comments