merge method
合并分片文件,并创建远端文件
Implementation
Future<UploadSuccess> merge({
required String remotePath,
required String localPath,
required String uploadid,
required List<String> blockMd5List,
UploadRenameRtype rtype = UploadRenameRtype.alwaysRename,
}) async {
final method = 'create';
var isdir = FileSystemEntity.isDirectorySync(localPath);
String size;
if (isdir) {
// 文件夹
size = '0';
} else if (FileSystemEntity.isFileSync(localPath)) {
size = File(localPath).lengthSync().toString();
} else {
throw Exception('不支持的类型');
}
final bodyParams = {
'path': Uri.encodeComponent(remotePath),
'size': size,
'isdir': isdir ? '1' : '0',
'uploadid': uploadid,
'rtype': rtype.index.toString(),
'block_list': json.encode(blockMd5List),
};
final map = await _post(
method: method,
bodyParams: bodyParams,
);
return UploadSuccess.fromJson(map);
}