uploadBytes method
- @Deprecated('Use uploadFiles instead for better flexibility and batch upload support')
- @override
Uploads a file to the backend from a list of bytes.
If not provided, mimeType defaults to application/octet-stream.
Throws an ApiException if the upload fails.
Deprecated: Use uploadFiles instead for better flexibility and batch upload support.
Implementation
@Deprecated(
'Use uploadFiles instead for better flexibility and batch upload support')
@override
Future<FileMetadata> uploadBytes({
required String fileName,
required List<int> fileContents,
String? fileId,
String? bucketId,
String mimeType = applicationOctetStreamType,
Map<String, dynamic>? metadata,
UploadProgressCallback? onUploadProgress,
}) async {
final fileData = FileData(
Uint8List.fromList(fileContents),
filename: fileName,
contentType: mimeType,
);
final uploadMetadata = (fileId != null || metadata != null)
? UploadFileMetadata(id: fileId, name: fileName, metadata: metadata)
: null;
final results = await uploadFiles(
files: [fileData],
bucketId: bucketId,
metadataList: uploadMetadata != null ? [uploadMetadata] : null,
onUploadProgress: onUploadProgress,
);
return results.first;
}