ObjectVersion.fromXml constructor

ObjectVersion.fromXml(
  1. XmlElement xml
)

Implementation

ObjectVersion.fromXml(XmlElement xml) {
  eTag = getProp(xml, 'ETag')?.value;

  // Check for null before converting to uppercase
  final isLatestValue = getProp(xml, 'IsLatest')?.value;
  isLatest =
      isLatestValue != null ? isLatestValue.toUpperCase() == 'TRUE' : false;

  key = getProp(xml, 'Key')?.value;

  // Ensure 'LastModified' is parsed correctly only if non-null
  final lastModifiedProp = getProp(xml, 'LastModified')?.value;
  lastModified =
      lastModifiedProp != null ? DateTime.parse(lastModifiedProp) : null;

  // Check for null before creating an 'Owner' instance
  final ownerProp = getProp(xml, 'Owner');
  owner = ownerProp != null ? Owner.fromXml(ownerProp) : null;

  // Ensure 'Size' is parsed correctly only if non-null
  final sizeProp = getProp(xml, 'Size')?.value;
  size = sizeProp != null ? int.tryParse(sizeProp) : null;

  storageClass = getProp(xml, 'StorageClass')?.value;
  versionId = getProp(xml, 'VersionId')?.value;
}