安卓断点续传

header-icon
// 创建TusClient实例
TusClient client = new TusClient();
// 设置断点上传
client.enableResuming(new TusPreferences());
// 设置上传地址
client.setUploadCreationURL(new URL("http://example.com/files"));
// 创建文件上传
File file = new File("/path/to/file.txt");
TusUpload upload = new TusUpload(file);
// 开始上传
upload = client.upload(upload);
// 监听上传进度
upload.add TusUploader.UploadProgressListener() {
    @Override
    public void onProgress(long uploadedBytes, long totalBytes) {
        // 更新进度
    }
};
// 等待上传完成
upload.waitForUpload();

 

posted @ 2023-02-24 05:39  今年我十八岁  阅读(39)  评论(0编辑  收藏  举报