Fix block id length upto 8bytes only for azure gateway. (#5731)

This PR also reverts commit 2f9354b17e
to bring back 8 byte block id requirement for azure gateway.
master
Harshavardhana 7 years ago committed by kannappanr
parent 228c8f05f4
commit 35b3913d22
  1. 16
      cmd/gateway/azure/gateway-azure.go

@ -19,6 +19,7 @@ package azure
import ( import (
"bytes" "bytes"
"context" "context"
"crypto/rand"
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
@ -38,7 +39,6 @@ import (
"github.com/minio/minio/pkg/errors" "github.com/minio/minio/pkg/errors"
"github.com/minio/minio/pkg/hash" "github.com/minio/minio/pkg/hash"
sha256 "github.com/minio/sha256-simd" sha256 "github.com/minio/sha256-simd"
"github.com/skyrings/skyring-common/tools/uuid"
minio "github.com/minio/minio/cmd" minio "github.com/minio/minio/cmd"
) )
@ -354,12 +354,20 @@ func azureToObjectError(err error, params ...string) error {
} }
// mustGetAzureUploadID - returns new upload ID which is hex encoded 8 bytes random value. // mustGetAzureUploadID - returns new upload ID which is hex encoded 8 bytes random value.
// this 8 byte restriction is needed because Azure block id has a restriction of length
// upto 8 bytes.
func mustGetAzureUploadID() string { func mustGetAzureUploadID() string {
uuid, err := uuid.New() var id [8]byte
n, err := io.ReadFull(rand.Reader, id[:])
if err != nil { if err != nil {
panic(err) panic(fmt.Errorf("unable to generate upload ID for azure. %s", err))
}
if n != len(id) {
panic(fmt.Errorf("insufficient random data (expected: %d, read: %d)", len(id), n))
} }
return fmt.Sprintf("%x", uuid[:])
return hex.EncodeToString(id[:])
} }
// checkAzureUploadID - returns error in case of given string is upload ID. // checkAzureUploadID - returns error in case of given string is upload ID.

Loading…
Cancel
Save