0

I am trying to upload an image and the postman request is in base64 encoding, however a corrupted image is produced. The code for the upload is:

  byte[] byteArray = Encoding.UTF8.GetBytes(image);
            MemoryStream stream = new MemoryStream(byteArray);
            AddBlobRequest blobRequest = new AddBlobRequest()
            {
                ContainerName = ContainerName,
                SourceFileStream = stream,
                BlobName = fileName
            };
            BlobStorageManager.Instance.AddBlob(blobRequest);
  • 1
    Why not `Encoding.ASCII`? That could be the problem. – Salar Oct 14 '16 at 10:23
  • 3
    `Base64` is not encryption, its encoding. https://danielmiessler.com/study/encoding-encryption-hashing-obfuscation/#gs.CnAPcE8 – Dayan Oct 14 '16 at 12:06
  • `Encoding.UTF8.GetBytes()` does not convert an image to base64 encoding. It converts a string to UTF8 encoding. You need to use `Convert.ToBase64String()`. I'm going to mark this question as a duplicate. – Brian Rogers Oct 14 '16 at 14:22
  • change the UFT8 encoding to byte[] byteArray = Convert.FromBase64String(image); – Sanila Salim Oct 18 '16 at 06:57

0 Answers0