java 後臺刪除 七牛雲 資料
阿新 • • 發佈:2018-11-17
目的:java 後臺刪除 七牛雲 資料
程式碼:
package com.xdx97.backstage; import com.qiniu.common.Zone; import com.qiniu.http.Response; import com.qiniu.storage.BucketManager; import com.qiniu.storage.Configuration; import com.qiniu.util.Auth; public class Test { public static void main(String[] args) { Auth auth = Auth.create("填寫你的AK", "填寫你的SK"); Configuration config = new Configuration(Zone.autoZone()); BucketManager bucketMgr = new BucketManager(auth, config); //指定需要刪除的檔案,和檔案所在的儲存空間 String bucketName = "xxx"; String key = "xxx"; try { Response delete = bucketMgr.delete(bucketName, key); delete.close(); }catch (Exception e){ e.printStackTrace(); } System.out.println("結束了"); } }