|
@@ -50,8 +50,8 @@ import com.aliyun.oss.model.PutObjectRequest;
|
|
|
public class OssAliyun {
|
|
|
|
|
|
private static String endpoint = "http://oss-cn-shanghai.aliyuncs.com";
|
|
|
- private static String accessKeyId = "IvS323TIcWUT57MG";
|
|
|
- private static String accessKeySecret = "dYml7rvT8stQkoSjMYlfRTxNj9dEsI";
|
|
|
+ private static String accessKeyId = "LTAI4FwTqQ2grekcxanKHnBL";
|
|
|
+ private static String accessKeySecret = "90nz7r8aImh2NhcNh0HAg8xiOJtn5V";
|
|
|
private static String bucketName = "mooctest-site";
|
|
|
|
|
|
public static void uploadFile(String objectName,File file) throws IOException {
|
|
@@ -190,4 +190,31 @@ public class OssAliyun {
|
|
|
reader.close();
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[]arg){
|
|
|
+ OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
|
+ String objectName="paperjson/1492-2612.json";
|
|
|
+ try {
|
|
|
+ /*
|
|
|
+ * Delete an object
|
|
|
+ */
|
|
|
+ System.out.println("Deleting an object\n");
|
|
|
+ ossClient.deleteObject(bucketName, objectName);
|
|
|
+
|
|
|
+ } catch (OSSException oe) {
|
|
|
+ System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
|
|
+ + "but was rejected with an error response for some reason.");
|
|
|
+ System.out.println("Error Message: " + oe.getErrorMessage());
|
|
|
+ System.out.println("Error Code: " + oe.getErrorCode());
|
|
|
+ System.out.println("Request ID: " + oe.getRequestId());
|
|
|
+ System.out.println("Host ID: " + oe.getHostId());
|
|
|
+ } catch (ClientException ce) {
|
|
|
+ System.out.println("Caught an ClientException, which means the client encountered "
|
|
|
+ + "a serious internal problem while trying to communicate with OSS, "
|
|
|
+ + "such as not being able to access the network.");
|
|
|
+ System.out.println("Error Message: " + ce.getMessage());
|
|
|
+ } finally {
|
|
|
+ ossClient.shutdown();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|