Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AzCopyV10] Add in content-md5 to available list properties #2033

Merged
merged 18 commits into from
Mar 28, 2023
Merged
2 changes: 1 addition & 1 deletion cmd/helpMessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const listCmdShortDescription = "List the entities in a given resource"
const listCmdLongDescription = `List the entities in a given resource. Blob, Files, and ADLS Gen 2 containers, folders, and accounts are supported.`

const listCmdExample = "azcopy list [containerURL] --properties [semicolon(;) separated list of attributes " +
"(LastModifiedTime, VersionId, BlobType, BlobAccessTier, ContentType, ContentEncoding, LeaseState, LeaseDuration, LeaseStatus) " +
"(LastModifiedTime, VersionId, BlobType, BlobAccessTier, ContentType, ContentEncoding, ContentMD5, LeaseState, LeaseDuration, LeaseStatus) " +
"enclosed in double quotes (\")]"

// ===================================== LOGIN COMMAND ===================================== //
Expand Down
6 changes: 5 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"fmt"
"strconv"
"strings"
"encoding/base64"

"github.com/Azure/azure-pipeline-go/pipeline"

Expand Down Expand Up @@ -54,6 +55,7 @@ const (
blobAccessTier validProperty = "BlobAccessTier"
contentType validProperty = "ContentType"
contentEncoding validProperty = "ContentEncoding"
contentMD5 validProperty = "ContentMD5"
leaseState validProperty = "LeaseState"
leaseDuration validProperty = "LeaseDuration"
leaseStatus validProperty = "LeaseStatus"
Expand All @@ -63,7 +65,7 @@ const (
// validProperties returns an array of possible values for the validProperty const type.
func validProperties() []validProperty {
return []validProperty{lastModifiedTime, versionId, blobType, blobAccessTier,
contentType, contentEncoding, leaseState, leaseDuration, leaseStatus, archiveStatus}
contentType, contentEncoding, contentMD5, leaseState, leaseDuration, leaseStatus, archiveStatus}
}

func (raw *rawListCmdArgs) parseProperties(rawProperties string) []validProperty {
Expand Down Expand Up @@ -177,6 +179,8 @@ func (cooked cookedListCmdArgs) processProperties(object StoredObject) string {
builder.WriteString(propertyStr + ": " + object.contentType + "; ")
case contentEncoding:
builder.WriteString(propertyStr + ": " + object.contentEncoding + "; ")
case contentMD5:
builder.WriteString(propertyStr + ": " + base64.StdEncoding.EncodeToString(object.md5) + "; ")
case leaseState:
builder.WriteString(propertyStr + ": " + string(object.leaseState) + "; ")
case leaseStatus:
Expand Down