Skip to content

Commit

Permalink
azurerm_storage_share_file - Base64 to hex encoding before setting …
Browse files Browse the repository at this point in the history
…`content_md5` (hashicorp#27108)
  • Loading branch information
magodo authored Aug 22, 2024
1 parent af0806e commit 5e91f75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion internal/services/storage/storage_share_file_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,17 @@ func resourceStorageShareFileRead(d *pluginsdk.ResourceData, meta interface{}) e
}
d.Set("content_type", props.ContentType)
d.Set("content_encoding", props.ContentEncoding)
d.Set("content_md5", props.ContentMD5)

// Set the ContentMD5 value to md5 hash in hex
contentMD5 := ""
if props.ContentMD5 != "" {
contentMD5, err = convertBase64ToHexEncoding(props.ContentMD5)
if err != nil {
return fmt.Errorf("converting hex to base64 encoding for content_md5: %v", err)
}
}
d.Set("content_md5", contentMD5)

d.Set("content_disposition", props.ContentDisposition)

if props.ContentLength == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ resource "azurerm_storage_share_file" "test" {
name = "test"
storage_share_id = azurerm_storage_share.test.id
source = "%s"
source = "%[2]s"
content_md5 = filemd5(%[2]q)
metadata = {
hello = "world"
Expand Down

0 comments on commit 5e91f75

Please sign in to comment.