Ejemplo n.º 1
0
 public static boolean isExisted(String path, KuaipanAPI api)
     throws KuaipanIOException, KuaipanAuthExpiredException {
   try {
     api.metadata(path, null);
   } catch (KuaipanServerException e) {
     if (e.code == 404 && e.msg.equals("file not exist")) return false;
   }
   return true;
 }
Ejemplo n.º 2
0
 public static String upload(KuaipanAPI api, String path, long size)
     throws KuaipanIOException, KuaipanServerException, KuaipanAuthExpiredException {
   long size_before = KPTestUtility.randomSize();
   String upload_content = KPTestUtility.generateByteString((int) size);
   InputStream is = new ByteArrayInputStream(upload_content.getBytes());
   api.uploadFile(path, is, size_before, true, new SleepyProgressListener());
   try {
     is.close();
   } catch (IOException e) {
   }
   return upload_content;
 }