上传/下载接口
KY_startDownload
- 功能描述:
- 开始文件下载。使用 KY_registerSDKListener 获取下载进度。需要在 KY_Connect 连线成功之后进行调用。
接口定义
public abstract void KY_startDownload(KYCamera.KYTransferType type, String dirPath, int channel);参数说明
| 参数 | 类型 | 说明 | 
|---|---|---|
| type | 传输方式 | |
| dirPath | string | 沙盒目录 | 
| channel | int | 进行下载的通道,默认0 | 
回调说明
暂无
返回码
暂无
代码示例
public void download() {
	//这里以下载时间戳为1746668220000L的sd卡录像为例
	List sTimeDayList = new ArrayList<>();
	sTimeDayList.add(new STimeDay(1746668220000L));
	//发送command,告知设备,app需要下载文件。 0x9029是psc定义的下载指令,上层可自定义
	CommandDownloadEvent command = new CommandDownloadEvent();
	byte[] bytes = command.request(sTimeDayList);
	int type = command.getRequestType();//0x9029
	mKYCamera.KY_SendIOCtrlToChannel(KYCamera.DEFAULT_AV_CHANNEL, type, bytes);
	//在收到设备回复后,即可使用KY_startDownload开始下载。请注意,设备需要提前对接好下载功能
}
......省略代码
public void KY_DidReceiveIOCtrlWithUid(String uid, int avChannel, int type, byte[] data, int dataSize) {
	if (type == AVIOCTRLDEFs.IOTYPE_USER_IPCAM_EVENT_DOWNLOAD_FILE_RESP) {
		//收到设备回复的下载指令,开始下载
		CommandDownloadEvent command = new CommandDownloadEvent();
		command.response(data);
		//目前是测试单个下载,所以command.list 只有一个
		if (command.list.isEmpty()) {
			return;
		}
		int downAvChannel = command.list.get(0);
		String dirPath = "/sdcard/Android/data/com.tutk.kalay1";
		mKYCamera.KY_startDownload(KYCamera.KYTransferType.AVAPI, dirPath, downAvChannel);
	}
} KY_stopDownload
- 功能描述:
- 停止文件下载。
接口定义
public abstract void KY_stopDownload(KYCamera.KYTransferType type, int channel);参数说明
| 参数 | 类型 | 说明 | 
|---|---|---|
| type | 传输方式 | |
| channel | int | 进行下载的通道,默认0 | 
回调说明
暂无
返回码
暂无
代码示例
暂无
KY_startUpload
- 功能描述:
- 开始文件上传。使用 KY_registerSDKListener 获取上传进度。需要在 KY_Connect 连线成功之后进行调用。
接口定义
public abstract void KY_startUpload(KYCamera.KYTransferType type, String filePath, int channel);参数说明
| 参数 | 类型 | 说明 | 
|---|---|---|
| type | 传输方式 | |
| filePath | string | 文件完整沙盒路径 | 
| channel | int | 进行上传的通道,默认0 | 
回调说明
暂无
返回码
暂无
代码示例
//文件上传
public void upload() {
    //这里以上传沙盒文件test.mp4为例
    File file = new File("/sdcard/Android/data/com.tutk.kalay1/test.mp4");
    List fileNameList = new ArrayList<>();
    fileNameList.add(file.getName());
    //发送command,告知设备,app需要上传文件。 0x9027是psc定义的下载指令,上层可自定义
    CommandUploadFile command = new CommandUploadFile();
    byte[] bytes = command.request(AVIOCTRLDEFs.TKTransferType_AVAPI, fileNameList);
    int type = command.getRequestType();//0x9027
    mKYCamera.KY_SendIOCtrlToChannel(KYCamera.DEFAULT_AV_CHANNEL, type, bytes);
    //在收到设备回复后,即可使用KY_startUpload开始上传。请注意,设备需要提前对接好上传功能
}
......省略代码
public void KY_DidReceiveIOCtrlWithUid(String uid, int avChannel, int type, byte[] data, int dataSize) {
    if (type == AVIOCTRLDEFs.IOTYPE_USER_IPCAM_UPLOAD_FILE_RESP) {
        //收到设备回复的上传指令,开始上传
        CommandUploadFile command = new CommandUploadFile();
        command.response(data);
        //目前是测试单个上传,所以command.list 只有一个
        if (command.list.isEmpty()) {
            return;
        }
        int uploadAvChannel = command.list.get(0);
        String filePath = "/sdcard/Android/data/com.tutk.kalay1/test.mp4";
        mKYCamera.KY_startUpload(KYCamera.KYTransferType.AVAPI, filePath, uploadAvChannel);
    }
} KY_stopUpload
- 功能描述:
- 停止文件上传。
接口定义
public abstract void KY_stopUpload(KYCamera.KYTransferType type, int channel);参数说明
| 参数 | 类型 | 说明 | 
|---|---|---|
| type | 传输方式 | |
| channel | int | 进行上传的通道,默认0 | 
回调说明
暂无
返回码
暂无
代码示例
暂无

