Code Monkey home page Code Monkey logo

Comments (8)

wushuai1415 avatar wushuai1415 commented on June 13, 2024

2.9.11是支持的,不过存在一些问题,2.9.13修复了,所以最好升级到2.9.13。
// 填写Bucket名称,例如examplebucket
String bucketName = "examplebucket";
// 填写Object完整路径,例如exampledir/exampleobject.txt。Object完整路径中不能包含Bucket名称
String objectKey = "exampledir/exampleobject.txt";
// 下载文件路径
String downloadFilePath = "/storage/emulated/0/oss/examplefile.txt";
ResumableDownloadRequest request = new ResumableDownloadRequest(bucketName, objectKey, downloadFilePath);
// 设置分片大小
request.setPartSize(100 * 1024);
// 开启断点记录
request.setEnableCheckPoint(true);
// 设置断点记录文件路径
request.setCheckPointFilePath("/storage/emulated/0/oss");
request.setProgressListener(new OSSProgressCallback() {
@OverRide
public void onProgress(Object request, long currentSize, long totalSize) {
Log.d("ResumableDownload", "currentSize: " + currentSize + " totalSize: " + totalSize);
}
});
OSSAsyncTask task = mOss.asyncResumableDownload(request, new OSSCompletedCallback<ResumableDownloadRequest, ResumableDownloadResult>() {
@OverRide
public void onSuccess(ResumableDownloadRequest request, ResumableDownloadResult result) {
Log.d("ResumableDownload", "DownloadSuccess");
}
@OverRide
public void onFailure(ResumableDownloadRequest request, ClientException clientException, ServiceException serviceException) {
// 请求异常。
if (clientException != null) {
// 客户端异常,例如网络异常等。
clientException.printStackTrace();
}
if (serviceException != null) {
// 服务端异常。
Log.e("ErrorCode", serviceException.getErrorCode());
Log.e("RequestId", serviceException.getRequestId());
Log.e("HostId", serviceException.getHostId());
Log.e("RawMessage", serviceException.getRawMessage());
}
}
});

from aliyun-oss-android-sdk.

ouy3xx avatar ouy3xx commented on June 13, 2024

好的,我再试试看,这边断点续载是支持同步和异步的吧?项目这边因为有界面下载文件才能跳转播放,请问同步的也是上面这个示例代码吗?

from aliyun-oss-android-sdk.

wushuai1415 avatar wushuai1415 commented on June 13, 2024

好的,我再试试看,这边断点续载是支持同步和异步的吧?项目这边因为有界面下载文件才能跳转播放,请问同步的也是上面这个示例代码吗?

同步把asyncResumableDownload 换成syncResumableDownload方法

from aliyun-oss-android-sdk.

ouy3xx avatar ouy3xx commented on June 13, 2024

同步过程中,如果网络异常,然后恢复,是否会继续下载直至完成?

from aliyun-oss-android-sdk.

ouy3xx avatar ouy3xx commented on June 13, 2024

请问上面的问题,可以吗?

from aliyun-oss-android-sdk.

wushuai1415 avatar wushuai1415 commented on June 13, 2024

请问上面的问题,可以吗?

网络中断后sdk会先重试,如果重试失败,需要再次调用断点下载的代码才会继续下载

from aliyun-oss-android-sdk.

ouy3xx avatar ouy3xx commented on June 13, 2024

好的,那我再试试,又不懂的再来请教了,感谢!

from aliyun-oss-android-sdk.

ouy3xx avatar ouy3xx commented on June 13, 2024

感谢,已经测试成功了!

from aliyun-oss-android-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.