uploadBytes method
Uploads a file to the backend from a list of bytes.
If not provided, contentType
defaults to application/octet-stream
.
Throws an ApiException if the upload fails.
Implementation
Future<FileMetadata> uploadBytes({
required String filePath,
required List<int> bytes,
String contentType = applicationOctetStreamType,
UploadProgressCallback? onUploadProgress,
}) async {
final file = http.MultipartFile.fromBytes(
'file',
bytes,
filename: filePath,
contentType: MediaType.parse(contentType),
);
return await _apiClient.postMultipart<FileMetadata>(
_objectPath(filePath),
headers: _session.authenticationHeaders,
files: [file],
responseDeserializer: FileMetadata.fromJson,
onUploadProgress: onUploadProgress,
);
}