文件下载失败
0
设备: Phantom 4 RTK.操作:下载图片.
说明: 拍照时我把文件信息存了起来,包括fileName,size,index,fileType,然后自己构造成mediaFile,camera设置成了download模式,然后调用mediaFile.fetchFileData()方法. 难道是设备不支持下载文件吗?
执行结果:"=======>onFailure"Not Support"
具体代码:
/**
* 下载文件帮助类
*/
public class DJIDownloadMediaFileUtil {
String TAG = this.getClass().getSimpleName();
public void downloadMediaFile(EntityWaypoint entityWaypoint) {
MediaFile mediaFile = new MediaFile.Builder().fileName(entityWaypoint.getFileName()).fileSize(entityWaypoint.getFileSize()).index(entityWaypoint.getFileIndex()).downloadedSize(entityWaypoint.getFileDownloadSize()).mediaType(MediaFile.MediaType.find(entityWaypoint.getFileType())).build();
if (mediaFile == null) {
LogUtil.logInfo(TAG, "=======>mediaFile == null");
return;
}
LogUtil.logInfo(TAG, "=======>fileName:"+entityWaypoint.getFileName()+"fileSize:"+entityWaypoint.getFileSize()+",fileIndex:"+entityWaypoint.getFileIndex()+",downloadedSize:"+entityWaypoint.getFileDownloadSize()+",mediaType:"+entityWaypoint.getFileType());
Camera camera = DJIProductUtils.getCameraInstance();
if (camera == null) {
LogUtil.logInfo(TAG, "=======>camera == null");
return;
}
MediaManager mediaManager = camera.getMediaManager();
if (mediaManager == null) {
LogUtil.logInfo(TAG, "=======>mediaManager == null");
return;
}
String rootPath = Environment.getExternalStorageDirectory().getPath();
String dataTimeStr = entityWaypoint.getDataTime();
dataTimeStr = dataTimeStr.replaceAll("-", "");
dataTimeStr = dataTimeStr.substring(0, 8);
String filePath = entityWaypoint.getLineName() + File.separator + entityWaypoint.getTowerName() + File.separator + dataTimeStr;
filePath = filePath.replaceAll("#", "");
File destDir = new File(Environment.getExternalStorageDirectory().
getPath() + "/IntelligentPatrol/" + filePath);
LogUtil.logInfo(TAG, "=======> fileName:" + entityWaypoint.getFileName());
if (!destDir.exists()) {
destDir.mkdirs();
}
LogUtil.logInfo(TAG, "=======>" + destDir.getAbsolutePath());
camera.setMode(SettingsDefinitions.CameraMode.MEDIA_DOWNLOAD,
new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError djiError) {
if (null == djiError) {
LogUtil.logInfo(TAG, "=======>camera.setMode MEDIA_DOWNLOAD Success");
} else {
LogUtil.logInfo(TAG, "=======>camera.setMode MEDIA_DOWNLOAD fail " + djiError.getDescription());
}
}
});
mediaFile.fetchFileData(destDir, entityWaypoint.getFileName(), new DownloadListener<String>() {
@Override
public void onStart() {
LogUtil.logInfo(TAG, "=======>onStart");
}
@Override
public void onRateUpdate(long l, long l1, long l2) {
LogUtil.logInfo(TAG, "=======>onRateUpdate" + l + ">" + l1 + ">" + l2);
}
@Override
public void onProgress(long l, long l1) {
LogUtil.logInfo(TAG, "=======>onProgress" + l + ">" + l1);
}
@Override
public void onSuccess(String s) {
LogUtil.logInfo(TAG, "=======>onSuccess" + s);
}
@Override
public void onFailure(DJIError djiError) {
LogUtil.logInfo(TAG, "=======>onFailure" + djiError.getDescription());
}
});
}
}
|
|
|
|