putObject method
Uploads the object. Returns the ETag of the uploaded object.
Implementation
Future<String> putObject(
String bucket,
String object,
Stream<Uint8List> data, {
int? size,
int? chunkSize,
Map<String, String>? metadata,
void Function(int)? onProgress,
}) async {
MinioInvalidBucketNameError.check(bucket);
MinioInvalidObjectNameError.check(object);
if (size != null && size < 0) {
throw MinioInvalidArgumentError('invalid size value: $size');
}
if (chunkSize != null && chunkSize < 5 * 1024 * 1024) {
throw MinioInvalidArgumentError('Minimum chunk size is 5MB');
}
metadata = prependXAMZMeta(metadata ?? <String, String>{});
final partSize = chunkSize ?? _calculatePartSize(size ?? maxObjectSize);
final uploader = MinioUploader(
this,
_client,
bucket,
object,
partSize,
metadata,
onProgress,
);
final chunker = MinChunkSize(partSize);
final etag = await data.transform(chunker).pipe(uploader);
return etag.toString();
}