大疆社区
标题:
文件下载失败
[打印本页]
作者:
djiuser_pMzwK3t
时间:
2020-4-28
标题:
文件下载失败
本帖最后由 djiuser_pMzwK3troulj 于 2020-4-28 18:40 编辑
设备:
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());
}
});
}
}
作者:
想养一条边牧
时间:
2020-4-29
P4R不支持获取原图片fetchFileData,仅支持获取高清预览图。
作者:
Spacemarine
时间:
2020-4-29
楼上正解
作者:
小鱼人
时间:
2020-4-29
想养一条边牧
4-29 10:40
[图片]
P4R不支持获取原图片fetchFileData,仅支持获取高清预览图。
哭着说谢谢...
欢迎光临 大疆社区 (https://bbs.dji.com/)
Powered by Discuz! X3.2