uploadBytes method

  1. @Deprecated('Use uploadFiles instead for better flexibility and batch upload support')
  2. @override
Future<FileMetadata> uploadBytes({
  1. required String fileName,
  2. required List<int> fileContents,
  3. String? fileId,
  4. String? bucketId,
  5. String mimeType = applicationOctetStreamType,
  6. Map<String, dynamic>? metadata,
  7. UploadProgressCallback? onUploadProgress,
})

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;
}