Loading files
8035964e1This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/openharness-1322671404.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
import 'dart:convert';
import 'dart:typed_data';
/// A `multipart/form-data` body holding one file, as plain bytes.
///
/// Built by hand rather than with Dio's `FormData`, because a `FormData` can be
/// sent exactly once: [BearerAuthInterceptor] answers a 401 by refreshing the
/// token and re-sending the SAME request, and a finalized `FormData` throws
/// there instead of going out again. Bytes go out as many times as asked.
({Uint8List bytes, String contentType}) multipartFileBody({
required String field,
required String filename,
required String fileContentType,
required Uint8List file,
required String boundary,
}) {
final head =
'--$boundary\r\n'
'Content-Disposition: form-data; name="$field"; filename="$filename"\r\n'
'Content-Type: $fileContentType\r\n\r\n';
final bytes =
(BytesBuilder(copy: false)
..add(utf8.encode(head))
..add(file)
..add(utf8.encode('\r\n--$boundary--\r\n')))
.takeBytes();
return (bytes: bytes, contentType: 'multipart/form-data; boundary=$boundary');
}
8035964e1This file is pinned to the selected release. Download the original to open it in your design tool.