mergePdfs method

Future<Media> mergePdfs(
  1. List<File> pdfs, {
  2. String? folder,
})

Implementation

Future<Media> mergePdfs(List<File> pdfs, {String? folder}) async {
  final response = await _makeRequest(
    'POST',
    'merge',
    files: pdfs
        .asMap()
        .entries
        .map((e) => MultipartFile(
              'files',
              e.value.openRead(),
              e.value.lengthSync(),
              filename: "file-${e.key}",
              contentType: MediaType.parse(
                  lookupMimeType(e.value.path) ?? 'application/octet-stream'),
            ))
        .toList(),
    formFields: folder != null ? {'folder': folder} : null,
  );
  return Media.fromJson(response["data"]);
}