| 640 | } |
| 641 | |
| 642 | std::shared_ptr<const KeyValueMetadata> PropertiesToMetadata( |
| 643 | const Blobs::Models::BlobProperties& properties) { |
| 644 | auto metadata = std::make_shared<KeyValueMetadata>(); |
| 645 | // Not supported yet: |
| 646 | // * properties.ObjectReplicationSourceProperties |
| 647 | // |
| 648 | // They may have the same key defined in the following |
| 649 | // metadata->Append() list. If we have duplicated key in metadata, |
| 650 | // the first value may be only used by users because |
| 651 | // KeyValueMetadata::Get() returns the first found value. Note that |
| 652 | // users can use all values by using KeyValueMetadata::keys() and |
| 653 | // KeyValueMetadata::values(). |
| 654 | if (properties.ImmutabilityPolicy.HasValue()) { |
| 655 | metadata->Append("Immutability-Policy-Expires-On", |
| 656 | properties.ImmutabilityPolicy.Value().ExpiresOn.ToString()); |
| 657 | metadata->Append("Immutability-Policy-Mode", |
| 658 | properties.ImmutabilityPolicy.Value().PolicyMode.ToString()); |
| 659 | } |
| 660 | metadata->Append("Content-Type", properties.HttpHeaders.ContentType); |
| 661 | metadata->Append("Content-Encoding", properties.HttpHeaders.ContentEncoding); |
| 662 | metadata->Append("Content-Language", properties.HttpHeaders.ContentLanguage); |
| 663 | const auto& content_hash = properties.HttpHeaders.ContentHash.Value; |
| 664 | metadata->Append("Content-Hash", HexEncode(content_hash.data(), content_hash.size())); |
| 665 | metadata->Append("Content-Disposition", properties.HttpHeaders.ContentDisposition); |
| 666 | metadata->Append("Cache-Control", properties.HttpHeaders.CacheControl); |
| 667 | metadata->Append("Last-Modified", properties.LastModified.ToString()); |
| 668 | metadata->Append("Created-On", properties.CreatedOn.ToString()); |
| 669 | if (properties.ObjectReplicationDestinationPolicyId.HasValue()) { |
| 670 | metadata->Append("Object-Replication-Destination-Policy-Id", |
| 671 | properties.ObjectReplicationDestinationPolicyId.Value()); |
| 672 | } |
| 673 | metadata->Append("Blob-Type", properties.BlobType.ToString()); |
| 674 | if (properties.CopyCompletedOn.HasValue()) { |
| 675 | metadata->Append("Copy-Completed-On", properties.CopyCompletedOn.Value().ToString()); |
| 676 | } |
| 677 | if (properties.CopyStatusDescription.HasValue()) { |
| 678 | metadata->Append("Copy-Status-Description", properties.CopyStatusDescription.Value()); |
| 679 | } |
| 680 | if (properties.CopyId.HasValue()) { |
| 681 | metadata->Append("Copy-Id", properties.CopyId.Value()); |
| 682 | } |
| 683 | if (properties.CopyProgress.HasValue()) { |
| 684 | metadata->Append("Copy-Progress", properties.CopyProgress.Value()); |
| 685 | } |
| 686 | if (properties.CopySource.HasValue()) { |
| 687 | metadata->Append("Copy-Source", properties.CopySource.Value()); |
| 688 | } |
| 689 | if (properties.CopyStatus.HasValue()) { |
| 690 | metadata->Append("Copy-Status", properties.CopyStatus.Value().ToString()); |
| 691 | } |
| 692 | if (properties.IsIncrementalCopy.HasValue()) { |
| 693 | metadata->Append("Is-Incremental-Copy", |
| 694 | FormatValue<BooleanType>(properties.IsIncrementalCopy.Value())); |
| 695 | } |
| 696 | if (properties.IncrementalCopyDestinationSnapshot.HasValue()) { |
| 697 | metadata->Append("Incremental-Copy-Destination-Snapshot", |
| 698 | properties.IncrementalCopyDestinationSnapshot.Value()); |
| 699 | } |