uploadEmoticonCustomize method

Future<EmoticonUploadResult> uploadEmoticonCustomize({
  1. required Uint8List bytes,
  2. required String filename,
  3. CancelToken? cancelToken,
  4. void onSendProgress(
    1. int sent,
    2. int total
    )?,
})

上传自定义表情

POST /api/v1/emoticon/customize/upload,字段:file(png/jpg/jpeg/gif,≤5MB)。

Implementation

Future<EmoticonUploadResult> uploadEmoticonCustomize({
  required Uint8List bytes,
  required String filename,
  CancelToken? cancelToken,
  void Function(int sent, int total)? onSendProgress,
}) async {
  if (bytes.length > maxEmoticonBytes) {
    throw GoChatException('表情文件不能超过 5MB');
  }
  final form = FormData.fromMap({
    'file': MultipartFile.fromBytes(bytes, filename: filename),
  });
  final resp = await _net.http.postFormData(
    '/api/v1/emoticon/customize/upload',
    data: form,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
  );
  return EmoticonUploadResult.fromJson(resp);
}