uploadFile method
Upload a file to the provider.
dataBase64 — base64-encoded file data.
mediaType — media type of the file (e.g. "application/pdf").
optsJson — optional serialized UploadFileCallOptions.
Returns the JSON-serialized UploadFileResult, or throws on error.
Implementation
String uploadFile(String dataBase64, String mediaType, [String? optsJson]) {
_checkOpen();
return _withUtf8(dataBase64, (dataPtr) {
return _withUtf8(mediaType, (mediaPtr) {
final optsPtr = optsJson != null ? optsJson.toNativeUtf8() : nullptr;
try {
final resultPtr =
_ffi.fileUpload(_handle, dataPtr, mediaPtr, optsPtr);
return _readResult(_ffi, resultPtr);
} finally {
if (optsPtr != nullptr) calloc.free(optsPtr);
}
});
});
}