setFormData method

Future<FormData> setFormData(
  1. String filePath,
  2. String ossPath, {
  3. MediaType? contentType,
  4. String? fileName,
})

Implementation

Future<FormData> setFormData(String filePath, String ossPath,
    {MediaType? contentType, String? fileName}) async {
  assert(_singleton != null, '请先调用 initialize');
  fileName ??=
      '${DateTime.now().millisecondsSinceEpoch}-${filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length)}';
  return FormData.fromMap(<String, dynamic>{
    'file': await MultipartFile.fromFile(filePath, contentType: contentType),
    'key': ossPath,
    'policy': _policyBase64,
    'OSSAccessKeyId': _aliOSSAccessKeyId,
    'success_action_status': 200,
    'Signature': _signature,
    'Filename': fileName
  });
}