ChannelFileUploadRequest constructor
ChannelFileUploadRequest({
- required String channelUrl,
- required String requestId,
- required FileMessageParams params,
- OnUploadProgressCallback? onProgress,
Implementation
ChannelFileUploadRequest({
required String channelUrl,
required String requestId,
required FileMessageParams params,
OnUploadProgressCallback? onProgress,
}) : super() {
url = 'storage/file';
final fileSize = params.uploadFile.file?.lengthSync() ??
params.uploadFile.fileBytes?.lengthInBytes ??
0;
if (fileSize == 0) {
throw InvalidParameterError();
}
//upload size limit
if (state.uploadSizeLimit < fileSize) {
throw FileSizeLimitExceededError();
}
body = {
'channel_url': channelUrl,
'request_id': requestId,
'file': params.uploadFile,
};
params.thumbnailSizes?.asMap().forEach((index, value) =>
body['thumbnail${index + 1}'] =
'${value.width.round()},${value.height.round()}');
isMultipart = true;
progress = onProgress;
}